Apache9 commented on code in PR #5444:
URL: https://github.com/apache/hbase/pull/5444#discussion_r1342093040


##########
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/tls/X509Util.java:
##########
@@ -219,17 +219,17 @@ static String[] getDefaultCipherSuites(boolean 
useOpenSsl) {
 
   static String[] getDefaultCipherSuitesForJavaVersion(String javaVersion) {
     Objects.requireNonNull(javaVersion);
-    if (javaVersion.matches("\\d+")) {
-      // Must be Java 9 or later
-      LOG.debug("Using Java9+ optimized cipher suites for Java version {}", 
javaVersion);
-      return DEFAULT_CIPHERS_JAVA9;
-    } else if (javaVersion.startsWith("1.")) {
-      // Must be Java 1.8 or earlier
-      LOG.debug("Using Java8 optimized cipher suites for Java version {}", 
javaVersion);
-      return DEFAULT_CIPHERS_JAVA8;
-    } else {
-      LOG.debug("Could not parse java version {}, using Java8 optimized cipher 
suites",
-        javaVersion);
+
+    try {
+      int javaVersionInt = Integer.parseInt(javaVersion);
+      if (javaVersionInt >= 11) {
+        return DEFAULT_CIPHERS_JAVA11;
+      } else if (javaVersionInt >= 9) {
+        return DEFAULT_CIPHERS_JAVA9;
+      } else {
+        return DEFAULT_CIPHERS_JAVA8;
+      }
+    } catch (NumberFormatException ignore) {

Review Comment:
   I prefer the old way for testing whether we could parse the java version, 
NumberFormatException is a RuntimeException, usually we should not consider 
catching a RuntimeException, just avoid throwing it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to