You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2018/10/09 05:56:31 UTC

ignite git commit: IGNITE-9814: Hadoop: fixed native libraries update routine for Java 11. This closes #4925.

Repository: ignite
Updated Branches:
  refs/heads/master bc87ad9cb -> fe85345f3


IGNITE-9814: Hadoop: fixed native libraries update routine for Java 11. This closes #4925.


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

Branch: refs/heads/master
Commit: fe85345f33ff8d5443edbeb30a2e73bf132c1692
Parents: bc87ad9
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Tue Oct 9 08:56:23 2018 +0300
Committer: devozerov <pp...@gmail.com>
Committed: Tue Oct 9 08:56:23 2018 +0300

----------------------------------------------------------------------
 .../processors/hadoop/HadoopClassLoader.java    | 37 ++++++++++++++++----
 1 file changed, 30 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/fe85345f/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
index e2995bc..7dfc138 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.processors.hadoop;
 
+import java.util.Collections;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.internal.util.ClassCache;
@@ -176,11 +177,24 @@ public class HadoopClassLoader extends URLClassLoader implements ClassCache {
         }
 
         // Link libraries to class loader.
-        Vector<Object> ldrLibs = nativeLibraries(this);
+        Object ldrLibsObj = nativeLibraries(this);
 
-        synchronized (ldrLibs) {
-            ldrLibs.addAll(res);
+        if (ldrLibsObj instanceof Vector) {
+            Vector<Object> ldrLibs = (Vector<Object>)ldrLibsObj;
+
+            synchronized (ldrLibs) {
+                ldrLibs.addAll(res);
+            }
+        }
+        else if (ldrLibsObj instanceof ConcurrentHashMap) {
+            ConcurrentHashMap<Object, Object> ldrLibs = (ConcurrentHashMap<Object, Object>)ldrLibsObj;
+
+            synchronized (ldrLibs) {
+                for (Object nl : res)
+                    ldrLibs.put(nativeLibraryName(nl), nl);
+            }
         }
+
     }
 
     /**
@@ -213,9 +227,17 @@ public class HadoopClassLoader extends URLClassLoader implements ClassCache {
                 ClassLoader ldr = APP_CLS_LDR;
 
                 while (ldr != null) {
-                    Vector<Object> ldrLibObjs = nativeLibraries(ldr);
+                    Object ldrLibObject = nativeLibraries(ldr);
 
-                    synchronized (ldrLibObjs) {
+                    Collection ldrLibObjs = null;
+                    if (ldrLibObject instanceof Vector)
+                        ldrLibObjs = (Vector<Object>)ldrLibObject;
+                    else if (ldrLibObject instanceof ConcurrentHashMap)
+                        ldrLibObjs = ((ConcurrentHashMap)ldrLibObject).values();
+                    else
+                        ldrLibObjs = Collections.emptySet();
+
+                    synchronized (ldrLibObject) {
                         for (Object ldrLibObj : ldrLibObjs) {
                             String name = nativeLibraryName(ldrLibObj);
 
@@ -225,7 +247,8 @@ public class HadoopClassLoader extends URLClassLoader implements ClassCache {
 
                                     break;
                                 }
-                            } else {
+                            }
+                            else {
                                 if (name.contains(libName)) {
                                     libObj = ldrLibObj;
 
@@ -264,7 +287,7 @@ public class HadoopClassLoader extends URLClassLoader implements ClassCache {
      * @param ldr Class loaded.
      * @return Native libraries.
      */
-    private static Vector<Object> nativeLibraries(ClassLoader ldr) {
+    private static Object nativeLibraries(ClassLoader ldr) {
         assert ldr != null;
 
         return U.field(ldr, "nativeLibraries");