This is an automated email from the ASF dual-hosted git repository.

zuston pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git


The following commit(s) were added to refs/heads/master by this push:
     new f9c1393b2 [1387] improvement: compatibility with jdk8 when call 
JavaUtils.newConcurrentMap (#1389)
f9c1393b2 is described below

commit f9c1393b21a265642ddde466070bcc77eaae294c
Author: Qing <[email protected]>
AuthorDate: Thu Dec 21 09:52:44 2023 +0800

    [1387] improvement: compatibility with jdk8 when call 
JavaUtils.newConcurrentMap (#1389)
    
    ## What changes were proposed in this pull request?
    compatibility with jdk8 when call JavaUtils.newConcurrentMap
    
    ## Why are the changes needed?
    Fix: https://github.com/apache/incubator-uniffle/issues/1387
    
    ## Does this PR introduce any user-facing change?
    No.
    
    ## How was this patch tested?
---
 .../main/java/org/apache/uniffle/common/util/JavaUtils.java | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/common/src/main/java/org/apache/uniffle/common/util/JavaUtils.java 
b/common/src/main/java/org/apache/uniffle/common/util/JavaUtils.java
index ba28aedc9..bc556da3c 100644
--- a/common/src/main/java/org/apache/uniffle/common/util/JavaUtils.java
+++ b/common/src/main/java/org/apache/uniffle/common/util/JavaUtils.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.function.Function;
 
+import com.google.common.base.Enums;
 import org.apache.commons.lang3.JavaVersion;
 import org.apache.commons.lang3.SystemUtils;
 import org.slf4j.Logger;
@@ -29,6 +30,16 @@ import org.slf4j.LoggerFactory;
 
 public class JavaUtils {
   private static final Logger logger = 
LoggerFactory.getLogger(JavaUtils.class);
+  private static final String JAVA_9 = "JAVA_9";
+
+  public static boolean isJavaVersionAtLeastJava9() {
+    if (Enums.getIfPresent(JavaVersion.class, JAVA_9).isPresent()
+        && SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9)) {
+      return true;
+    } else {
+      return false;
+    }
+  }
 
   /** Closes the given object, ignoring IOExceptions. */
   public static void closeQuietly(Closeable closeable) {
@@ -42,7 +53,7 @@ public class JavaUtils {
   }
 
   public static <K, V> ConcurrentHashMap<K, V> newConcurrentMap() {
-    if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9)) {
+    if (isJavaVersionAtLeastJava9()) {
       return new ConcurrentHashMap<>();
     } else {
       return new ConcurrentHashMapForJDK8<>();

Reply via email to