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 2016/09/16 09:04:43 UTC

[5/7] ignite git commit: Minors.

Minors.


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

Branch: refs/heads/ignite-3912
Commit: 23c97cf8832d8ce865b2d183ac7836e29c6a0cd0
Parents: e63d305
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Sep 16 11:51:46 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Sep 16 11:51:46 2016 +0300

----------------------------------------------------------------------
 .../processors/hadoop/HadoopClassLoader.java    | 30 ++++++++++----------
 .../hadoop/HadoopClassLoaderTest.java           |  4 +--
 2 files changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/23c97cf8/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
index 8561021..82e8255 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
@@ -241,15 +241,7 @@ public class HadoopClassLoader extends URLClassLoader implements ClassCache {
             }
 
             if (isHadoopIgfs(name)) { // For Ignite Hadoop and IGFS classes we have to check if they depend on Hadoop.
-                Boolean hasDeps = cache.get(name);
-
-                if (hasDeps == null) {
-                    hasDeps = hasExternalDependencies(name);
-
-                    cache.put(name, hasDeps);
-                }
-
-                if (hasDeps)
+                if (hasExternalDependencies(name))
                     return loadClassExplicitly(name, resolve);
             }
 
@@ -347,14 +339,22 @@ public class HadoopClassLoader extends URLClassLoader implements ClassCache {
      * @return {@code True} if class has external dependencies.
      */
     boolean hasExternalDependencies(String clsName) {
-        CollectingContext ctx = new CollectingContext();
+        Boolean hasDeps = cache.get(name);
 
-        ctx.annVisitor = new CollectingAnnotationVisitor(ctx);
-        ctx.mthdVisitor = new CollectingMethodVisitor(ctx, ctx.annVisitor);
-        ctx.fldVisitor = new CollectingFieldVisitor(ctx, ctx.annVisitor);
-        ctx.clsVisitor = new CollectingClassVisitor(ctx, ctx.annVisitor, ctx.mthdVisitor, ctx.fldVisitor);
+        if (hasDeps == null) {
+            CollectingContext ctx = new CollectingContext();
+
+            ctx.annVisitor = new CollectingAnnotationVisitor(ctx);
+            ctx.mthdVisitor = new CollectingMethodVisitor(ctx, ctx.annVisitor);
+            ctx.fldVisitor = new CollectingFieldVisitor(ctx, ctx.annVisitor);
+            ctx.clsVisitor = new CollectingClassVisitor(ctx, ctx.annVisitor, ctx.mthdVisitor, ctx.fldVisitor);
+
+            hasDeps = hasExternalDependencies(clsName, ctx);
+
+            cache.put(name, hasDeps);
+        }
 
-        return hasExternalDependencies(clsName, ctx);
+        return hasDeps;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/23c97cf8/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoaderTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoaderTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoaderTest.java
index 02d98d0..2fd7777 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoaderTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoaderTest.java
@@ -94,7 +94,7 @@ public class HadoopClassLoaderTest extends TestCase {
             CircularWithoutHadoop.class,
         };
 
-        for (Class c: positiveClasses)
+        for (Class c : positiveClasses)
             assertTrue(c.getName(), ldr.hasExternalDependencies(c.getName()));
 
         // Negative cases:
@@ -104,7 +104,7 @@ public class HadoopClassLoaderTest extends TestCase {
             Without.class,
         };
 
-        for (Class c: negativeClasses)
+        for (Class c : negativeClasses)
             assertFalse(c.getName(), ldr.hasExternalDependencies(c.getName()));
     }
 }
\ No newline at end of file