From d4456fed6bba7b5c3e6ec42d049f7724e567b580 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 --- .../io/quarkus/bootstrap/runner/RunnerClassLoader.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 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..d6bf167acdbb4 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 { @@ -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("");