Skip to content

Commit

Permalink
Move findLoadedClass to inside the lock
Browse files Browse the repository at this point in the history
Fixes #10031
  • Loading branch information
stuartwdouglas committed Jun 16, 2020
1 parent 1626772 commit 5af6c64
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

/**
* Classloader used for production application, using the multi jar strategy
*
*/
public class RunnerClassLoader extends ClassLoader {

Expand All @@ -33,7 +32,7 @@ public class RunnerClassLoader extends ClassLoader {
}

RunnerClassLoader(ClassLoader parent, Map<String, ClassLoadingResource[]> resourceDirectoryMap,
Set<String> parentFirstPackages) {
Set<String> parentFirstPackages) {
super(parent);
this.resourceDirectoryMap = resourceDirectoryMap;
this.parentFirstPackages = parentFirstPackages;
Expand All @@ -49,10 +48,6 @@ public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundExce
//note that for performance reasons this CL does not do parent first delegation
//although the intention is not for it to be a true isolated parent first CL
//'delegation misses' where the parent throws a ClassNotFoundException are very expensive
Class<?> loaded = findLoadedClass(name);
if (loaded != null) {
return loaded;
}
if (name.startsWith("java.")) {
return getParent().loadClass(name);
}
Expand All @@ -61,6 +56,10 @@ public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundExce
return getParent().loadClass(name);
}
synchronized (getClassLoadingLock(name)) {
Class<?> loaded = findLoadedClass(name);
if (loaded != null) {
return loaded;
}
ClassLoadingResource[] resources;
if (packageName == null) {
resources = resourceDirectoryMap.get("");
Expand Down

0 comments on commit 5af6c64

Please sign in to comment.