From fc9743c17ae084240b658b343905e7e49d071899 Mon Sep 17 00:00:00 2001 From: Sean Busbey Date: Wed, 30 May 2018 22:23:56 -0500 Subject: [PATCH] HBASE-20444 Addendum keep folks from looking at raw version component array. Signed-off-by: Andrew Purtell --- .../java/org/apache/hadoop/hbase/util/VersionInfo.java | 2 +- .../org/apache/hadoop/hbase/util/TestVersionInfo.java | 8 ++++++++ .../main/java/org/apache/hadoop/hbase/util/HBaseFsck.java | 3 +-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/VersionInfo.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/VersionInfo.java index 0f368f3375a..b57255aeed6 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/VersionInfo.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/VersionInfo.java @@ -140,7 +140,7 @@ public class VersionInfo { * "4.5.6-UNKNOW" returns ["4", "5", "6", "-4"] * @return the components of the version string */ - static String[] getVersionComponents(final String version) { + private static String[] getVersionComponents(final String version) { assert(version != null); String[] strComps = version.split("[\\.-]"); assert(strComps.length > 0); diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestVersionInfo.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestVersionInfo.java index 2e638cf7a17..b8d2f021a25 100644 --- a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestVersionInfo.java +++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestVersionInfo.java @@ -56,5 +56,13 @@ public class TestVersionInfo { assertTrue(VersionInfo.compareVersion("3.0.0-alpha-2", "3.0.0-alpha-11") < 0); assertTrue(VersionInfo.compareVersion("3.0.0-beta-2", "3.0.0-beta-11") < 0); assertTrue(VersionInfo.compareVersion("2.0.0-foobar", "2.0.0.1") < 0); + assertTrue(VersionInfo.compareVersion("2.any.any", "2.0.0") < 0); + assertTrue(VersionInfo.compareVersion("2.0.0", "2.any.any") > 0); + assertTrue(VersionInfo.compareVersion("2.any.any", "2.0.0-alpha-1") < 0); + assertTrue(VersionInfo.compareVersion("2.0.0-alpha-1", "2.any.any") > 0); + assertTrue(VersionInfo.compareVersion("2.any.any", "2.0.0-beta-5-SNAPSHOT") < 0); + assertTrue(VersionInfo.compareVersion("2.0.0-beta-5-SNAPSHOT", "2.any.any") > 0); + assertTrue(VersionInfo.compareVersion("2.any.any", "1.4.4") > 0); + assertTrue(VersionInfo.compareVersion("1.4.4", "2.any.any") < 0); } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java index 1f9c9ab1970..27fa6b747ec 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java @@ -5141,8 +5141,7 @@ public class HBaseFsck extends Configured implements Closeable { private boolean isOptionsSupported(String[] args) { boolean result = true; String hbaseServerVersion = status.getHBaseVersion(); - Object[] versionComponents = VersionInfo.getVersionComponents(hbaseServerVersion); - if (versionComponents[0] instanceof Integer && ((Integer) versionComponents[0]) >= 2) { + if (VersionInfo.compareVersion("2.any.any", hbaseServerVersion) < 0) { // Process command-line args. for (String arg : args) { if (unsupportedOptionsInV2.contains(arg)) {