<NME> Version.java
<BEF> /*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.accumulo.core.util;


import org.apache.accumulo.start.Main;
import org.apache.accumulo.start.spi.KeywordExecutable;

import com.google.auto.service.AutoService;

@AutoService(KeywordExecutable.class)
public class Version implements KeywordExecutable {

  public Version() {}

  public UsageGroup usageGroup() {
    return UsageGroup.CORE;
  }

  @Override
  public String description() {
    return "Prints Accumulo version";
  }

  @Override
  public void execute(final String[] args) throws Exception {
    Class<?> runTMP = Main.getClassLoader().loadClass("org.apache.accumulo.core.Constants");
    System.out.println(runTMP.getField("VERSION").get(null));
  }

}
  private void parse(String everything) {
    Pattern pattern = Pattern.compile("(([^-]*)-)?(\\d+)(\\.(\\d+)(\\.(\\d+))?)?(-(.*))?");
    Matcher parser = pattern.matcher(everything);
    if (!parser.matches())
      throw new IllegalArgumentException("Unable to parse: " + everything + " as a version");

    if (parser.group(1) != null)
      package_ = parser.group(2);

<MSG> ACCUMULO-4554 Fail gracefully on unrecognized version

Change-Id: I6bc961816ffe23bfd82c34cdaf450791ecc303bf

<DFF> @@ -21,11 +21,14 @@ import java.util.regex.Pattern;
 
 import org.apache.accumulo.start.Main;
 import org.apache.accumulo.start.spi.KeywordExecutable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.auto.service.AutoService;
 
 @AutoService(KeywordExecutable.class)
 public class Version implements KeywordExecutable {
+  private static final Logger log = LoggerFactory.getLogger(Version.class);
 
   public Version() {}
 
@@ -58,8 +61,10 @@ public class Version implements KeywordExecutable {
   private void parse(String everything) {
     Pattern pattern = Pattern.compile("(([^-]*)-)?(\\d+)(\\.(\\d+)(\\.(\\d+))?)?(-(.*))?");
     Matcher parser = pattern.matcher(everything);
-    if (!parser.matches())
-      throw new IllegalArgumentException("Unable to parse: " + everything + " as a version");
+    if (!parser.matches()) {
+      log.warn("Unable to parse '{}' as a version", everything);
+      return;
+    }
 
     if (parser.group(1) != null)
       package_ = parser.group(2);

{'addition_count': 7, 'commit_subject': 'ACCUMULO-4554 Fail gracefully on unrecognized version', 'deletion_count': 2, 'file_extension': '.java', 'lang': 'java', 'license': 'apache-2.0', 'repo_name': 'apache/accumulo'}