zstan commented on a change in pull request #8759:
URL: https://github.com/apache/ignite/pull/8759#discussion_r572667758



##########
File path: 
modules/core/src/main/java/org/apache/ignite/spi/deployment/local/LocalDeploymentSpi.java
##########
@@ -111,35 +110,60 @@
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public DeploymentResource findResource(String 
rsrcName) {
+    @Nullable @Override public DeploymentResource findResource(String 
rsrcName, @Nullable ClassLoader clsLdr) {
         assert rsrcName != null;
 
-        // Last updated class loader has highest priority in search.
-        for (Entry<ClassLoader, ConcurrentMap<String, String>> e : 
ldrRsrcs.descendingEntrySet()) {
+        if (clsLdr != null) {
+            ConcurrentMap<String, String> rsrcs = ldrRsrcs.get(clsLdr);
+
+            if (rsrcs == null)
+                return null;
+
+            return findResource0(rsrcs, rsrcName, clsLdr);
+        }
+
+        for (Entry<ClassLoader, ConcurrentMap<String, String>> e : 
ldrRsrcs.entrySet()) {
             ClassLoader ldr = e.getKey();
             ConcurrentMap<String, String> rsrcs = e.getValue();
 
-            String clsName = rsrcs.get(rsrcName);
+            DeploymentResourceAdapter res = findResource0(rsrcs, rsrcName, 
ldr);
 
-            // Return class if it was found in resources map.
-            if (clsName != null) {
-                // Recalculate resource name in case if access is performed by
-                // class name and not the resource name.
-                rsrcName = getResourceName(clsName, rsrcs);
+            if (res != null)
+                return res;
+        }
 
-                assert clsName != null;
+        return null;
+    }
 
-                try {
-                    Class<?> cls = Class.forName(clsName, true, ldr);
+    /**
+     * Finds appropriate resource.
+     *
+     * @param rsrcs Resources.
+     * @param rsrcName Class name or class alias to find class loader for.
+     * @param clsLdr desired class loader.
+     * @return Deployed class loader, or {@code null} if not deployed.
+     */
+    @Nullable private DeploymentResourceAdapter findResource0(Map<String, 
String> rsrcs, String rsrcName, ClassLoader clsLdr) {
+        String clsName = rsrcs.get(rsrcName);
 
-                    assert cls != null;
+        // Return class if it was found in resources map.
+        if (clsName != null) {
+            // Recalculate resource name in case if access is performed by
+            // class name and not the resource name.
+            rsrcName = getResourceName(clsName, rsrcs);
 
-                    // Return resource.
-                    return new DeploymentResourceAdapter(rsrcName, cls, ldr);
-                }
-                catch (ClassNotFoundException ignored) {
-                    // No-op.
-                }
+            assert clsName != null;
+
+            try {
+                Class<?> cls = Class.forName(clsName, true, clsLdr);
+
+                assert cls != null;
+
+                // Return resource.
+                return new DeploymentResourceAdapter(rsrcName, cls, clsLdr);
+            }
+            catch (ClassNotFoundException ignored) {

Review comment:
       while this method still calling from "stub part" : 
org.apache.ignite.spi.deployment.local.LocalDeploymentSpi#findResource(java.lang.String,
 java.lang.ClassLoader) i can`t remove 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.

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


Reply via email to