From 5af6c6484b37d52962326d067efa6428bd4dfdd1 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Tue, 16 Jun 2020 12:21:00 +1000 Subject: [PATCH] Move findLoadedClass to inside the lock Fixes #10031 --- .../quarkus/bootstrap/runner/RunnerClassLoader.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/RunnerClassLoader.java b/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/RunnerClassLoader.java index 921c41088b775..c3ad8e038bd0b 100644 --- a/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/RunnerClassLoader.java +++ b/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/RunnerClassLoader.java @@ -15,7 +15,6 @@ /** * Classloader used for production application, using the multi jar strategy - * */ public class RunnerClassLoader extends ClassLoader { @@ -33,7 +32,7 @@ public class RunnerClassLoader extends ClassLoader { } RunnerClassLoader(ClassLoader parent, Map resourceDirectoryMap, - Set parentFirstPackages) { + Set parentFirstPackages) { super(parent); this.resourceDirectoryMap = resourceDirectoryMap; this.parentFirstPackages = parentFirstPackages; @@ -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); } @@ -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("");