Minors.

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

Branch: refs/heads/ignite-3929-1
Commit: c9e665e22ced6401c9b76f41192c16866a4c4cbc
Parents: 00c3dc9
Author: vozerov-gridgain <voze...@gridgain.com>
Authored: Tue Sep 20 16:47:29 2016 +0300
Committer: vozerov-gridgain <voze...@gridgain.com>
Committed: Tue Sep 20 16:47:29 2016 +0300

----------------------------------------------------------------------
 .../processors/hadoop/HadoopClassLoader.java    | 35 ++++++++++++--------
 1 file changed, 21 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c9e665e2/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 be28de4..3bf841b 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
@@ -152,6 +152,7 @@ public class HadoopClassLoader extends URLClassLoader 
implements ClassCache {
      * @see <a 
href="http://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/invocation.html#library_version";>
      *     JNI specification</a>
      */
+    @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
     private void initializeNativeLibraries(@Nullable String[] usrLibs) {
         Collection<Object> res;
 
@@ -176,7 +177,9 @@ public class HadoopClassLoader extends URLClassLoader 
implements ClassCache {
         // Link libraries to class loader.
         Vector<Object> ldrLibs = nativeLibraries(this);
 
-        ldrLibs.addAll(res);
+        synchronized (ldrLibs) {
+            ldrLibs.addAll(res);
+        }
     }
 
     /**
@@ -185,6 +188,7 @@ public class HadoopClassLoader extends URLClassLoader 
implements ClassCache {
      * @param libs Libraries to initialize.
      * @return Initialized libraries.
      */
+    @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
     private static Collection<Object> 
initializeNativeLibraries0(Collection<NativeLibrary> libs) {
         assert Thread.holdsLock(LIBS_MUX);
 
@@ -205,24 +209,27 @@ public class HadoopClassLoader extends URLClassLoader 
implements ClassCache {
                 // Find library in class loader internals.
                 Object libObj = null;
 
-                ClassLoader ldr = HadoopClassLoader.class.getClassLoader();
+                ClassLoader ldr = APP_CLS_LDR;
 
                 while (ldr != null) {
-                    for (Object ldrLibObj : nativeLibraries(ldr)) {
-                        String name = nativeLibraryName(ldrLibObj);
+                    Vector<Object> ldrLibObjs = nativeLibraries(ldr);
 
-                        if (libFile.isAbsolute()) {
-                            if (F.eq(name, libFile.getCanonicalPath())) {
-                                libObj = ldrLibObj;
+                    synchronized (ldrLibObjs) {
+                        for (Object ldrLibObj : ldrLibObjs) {
+                            String name = nativeLibraryName(ldrLibObj);
 
-                                break;
-                            }
-                        }
-                        else {
-                            if (name.contains(libName)) {
-                                libObj = ldrLibObj;
+                            if (libFile.isAbsolute()) {
+                                if (F.eq(name, libFile.getCanonicalPath())) {
+                                    libObj = ldrLibObj;
+
+                                    break;
+                                }
+                            } else {
+                                if (name.contains(libName)) {
+                                    libObj = ldrLibObj;
 
-                                break;
+                                    break;
+                                }
                             }
                         }
                     }

Reply via email to