accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject accumulo git commit: ACCUMULO-4554 Fail gracefully on unrecognized version
Date Wed, 04 Jan 2017 23:38:42 GMT
Repository: accumulo
Updated Branches:
  refs/heads/master e88cb6288 -> 1474e1cfe


ACCUMULO-4554 Fail gracefully on unrecognized version

Change-Id: I6bc961816ffe23bfd82c34cdaf450791ecc303bf


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/1474e1cf
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/1474e1cf
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/1474e1cf

Branch: refs/heads/master
Commit: 1474e1cfe3da167ba88021ae50fc0d57b164bde0
Parents: e88cb62
Author: Josh Elser <elserj@apache.org>
Authored: Wed Jan 4 18:18:09 2017 -0500
Committer: Josh Elser <elserj@apache.org>
Committed: Wed Jan 4 18:18:40 2017 -0500

----------------------------------------------------------------------
 .../main/java/org/apache/accumulo/core/util/Version.java |  9 +++++++--
 .../java/org/apache/accumulo/core/util/TestVersion.java  | 11 ++++++-----
 2 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/1474e1cf/core/src/main/java/org/apache/accumulo/core/util/Version.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/Version.java b/core/src/main/java/org/apache/accumulo/core/util/Version.java
index 127b635..a2e900a 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/Version.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/Version.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/1474e1cf/core/src/test/java/org/apache/accumulo/core/util/TestVersion.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/util/TestVersion.java b/core/src/test/java/org/apache/accumulo/core/util/TestVersion.java
index af3f391..476c06f 100644
--- a/core/src/test/java/org/apache/accumulo/core/util/TestVersion.java
+++ b/core/src/test/java/org/apache/accumulo/core/util/TestVersion.java
@@ -55,10 +55,11 @@ public class TestVersion extends TestCase {
     assertTrue(v.getReleaseVersion() == 0);
     assertTrue(v.getEtcetera().equals("beta"));
 
-    try {
-      make("beta");
-      fail("Should have thrown an error");
-    } catch (IllegalArgumentException t) {}
+    v = make("beta");
+    assertTrue(v.getPackage() == null);
+    assertTrue(v.getMajorVersion() == 0);
+    assertTrue(v.getMinorVersion() == 0);
+    assertTrue(v.getReleaseVersion() == 0);
+    assertTrue(v.getEtcetera() == null);
   }
-
 }


Mime
View raw message