Repository: quarkusio/quarkus
Issue: JarRunnerIT fast jar test methods consistently failing on CI runs

I haven't been able to reproduce locally but `JarRunnerIT` test methods `testThatFastJarFormatWorks` and `testThatMutableFastJarWorks` have been failing regularly (across various Java versions) with condition timeout exception in CI runs. To help debug what's going, we recently merged this PR https://github.com/quarkusio/quarkus/pull/9960 which has now turned out to be useful, because a subsequent CI run failure[1] now has the following logs, from a failure of 
```
2020-06-15T19:48:44.8880973Z [ERROR] Tests run: 4, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 333.633 s <<< FAILURE! - in io.quarkus.maven.it.JarRunnerIT
2020-06-15T19:48:44.8882135Z [ERROR] testThatMutableFastJarWorks  Time elapsed: 307.78 s  <<< ERROR!
2020-06-15T19:48:44.8884800Z org.awaitility.core.ConditionTimeoutException: Condition with io.quarkus.maven.it.JarRunnerIT was not fulfilled within 1 minutes.
2020-06-15T19:48:45.0599036Z 	at io.quarkus.maven.it.JarRunnerIT.lambda$testThatMutableFastJarWorks$7(JarRunnerIT.java:150)
2020-06-15T19:48:45.0617135Z 	at
```


```
2020-06-15T19:48:27.1122162Z ####### LOG DUMP ON FAILURE (start) ######
2020-06-15T19:48:27.1124138Z Dumping logs that were generated in target/test-classes/projects/project-classic-console-output-mutable-fast-jar/target/output.log for an operation that resulted in org.awaitility.core.ConditionTimeoutException:
2020-06-15T19:48:27.1139467Z 
2020-06-15T19:48:27.1140673Z /opt/hostedtoolcache/AdoptOpenJDK/1.0.0-releases-8-hotspot-normal-latest/x64/jre/bin/java
2020-06-15T19:48:27.1141211Z -jar
2020-06-15T19:48:27.1141816Z /home/runner/work/quarkus/quarkus/integration-tests/maven/target/test-classes/projects/project-classic-console-output-mutable-fast-jar/target/quarkus-app/quarkus-run.jar
2020-06-15T19:48:27.1142172Z __  ____  __  _____   ___  __ ____  ______ 
2020-06-15T19:48:27.1142615Z  --/ __ \\/ / / / _ | / _ \\/ //_/ / / / __/ 
2020-06-15T19:48:27.1143056Z  -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\\ \\   
2020-06-15T19:48:27.1143512Z --\\___\\_\\____/_/ |_/_/|_/_/|_|\\____/___/   
2020-06-15T19:48:27.1144108Z 2020-06-15 19:43:26,858 ERROR [io.qua.application] (main) Failed to start application: java.lang.RuntimeException: Unable to start HTTP server
2020-06-15T19:48:27.1144450Z 	at io.quarkus.vertx.http.runtime.VertxHttpRecorder.doServerStart(VertxHttpRecorder.java:432)
2020-06-15T19:48:27.1144835Z 	at io.quarkus.vertx.http.runtime.VertxHttpRecorder.startServer(VertxHttpRecorder.java:198)
2020-06-15T19:48:27.1145878Z 	at io.quarkus.deployment.steps.VertxHttpProcessor$openSocket-2064782366.deploy_0(VertxHttpProcessor$openSocket-2064782366.zig:119)
2020-06-15T19:48:27.1146937Z 	at io.quarkus.deployment.steps.VertxHttpProcessor$openSocket-2064782366.deploy(VertxHttpProcessor$openSocket-2064782366.zig:36)
2020-06-15T19:48:27.1147338Z 	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:450)
2020-06-15T19:48:27.1147625Z 	at io.quarkus.runtime.Application.start(Application.java:90)
2020-06-15T19:48:27.1148044Z 	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:91)
2020-06-15T19:48:27.1149633Z 	at io.quarkus.runtime.Quarkus.run(Quarkus.java:61)
2020-06-15T19:48:27.1187782Z 	at io.quarkus.runtime.Quarkus.run(Quarkus.java:38)
2020-06-15T19:48:27.1188116Z 	at io.quarkus.runtime.Quarkus.run(Quarkus.java:106)
2020-06-15T19:48:27.1188601Z 	at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
2020-06-15T19:48:27.1188756Z 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2020-06-15T19:48:27.1192167Z 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2020-06-15T19:48:27.1192337Z 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2020-06-15T19:48:27.1192492Z 	at java.lang.reflect.Method.invoke(Method.java:498)
2020-06-15T19:48:27.1192641Z 	at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:31)
2020-06-15T19:48:27.1192795Z 	at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:18)
2020-06-15T19:48:27.1192992Z Caused by: java.util.concurrent.ExecutionException: java.lang.LinkageError: loader (instance of  io/quarkus/bootstrap/runner/RunnerClassLoader): attempted  duplicate class definition for name: "io/vertx/core/net/impl/VertxEventLoopGroup"
2020-06-15T19:48:27.1193182Z 	at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
2020-06-15T19:48:27.1193337Z 	at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1908)
2020-06-15T19:48:27.1193525Z 	at io.quarkus.vertx.http.runtime.VertxHttpRecorder.doServerStart(VertxHttpRecorder.java:403)
2020-06-15T19:48:27.1193676Z 	... 16 more
2020-06-15T19:48:27.1193855Z Caused by: java.lang.LinkageError: loader (instance of  io/quarkus/bootstrap/runner/RunnerClassLoader): attempted  duplicate class definition for name: "io/vertx/core/net/impl/VertxEventLoopGroup"
2020-06-15T19:48:27.1194170Z 	at java.lang.ClassLoader.defineClass1(Native Method)
2020-06-15T19:48:27.1194317Z 	at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
2020-06-15T19:48:27.1194470Z 	at io.quarkus.bootstrap.runner.RunnerClassLoader.loadClass(RunnerClassLoader.java:79)
2020-06-15T19:48:27.1194625Z 	at io.quarkus.bootstrap.runner.RunnerClassLoader.loadClass(RunnerClassLoader.java:44)
2020-06-15T19:48:27.1194783Z 	at io.vertx.core.http.impl.HttpServerImpl.<init>(HttpServerImpl.java:67)
2020-06-15T19:48:27.1194938Z 	at io.vertx.core.impl.VertxImpl.createHttpServer(VertxImpl.java:310)
2020-06-15T19:48:27.1195088Z 	at io.quarkus.vertx.http.runtime.VertxHttpRecorder$WebDeploymentVerticle.start(VertxHttpRecorder.java:759)
2020-06-15T19:48:27.1195245Z 	at io.vertx.core.Verticle.start(Verticle.java:66)
2020-06-15T19:48:27.1195394Z 	at io.vertx.core.impl.DeploymentManager.lambda$doDeploy$9(DeploymentManager.java:556)
2020-06-15T19:48:27.1195543Z 	at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:366)
2020-06-15T19:48:27.1195697Z 	at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38)
2020-06-15T19:48:27.1195857Z 	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
2020-06-15T19:48:27.1196022Z 	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
2020-06-15T19:48:27.1196178Z 	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
2020-06-15T19:48:27.1196334Z 	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
2020-06-15T19:48:27.1196490Z 	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
2020-06-15T19:48:27.1196631Z 	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
2020-06-15T19:48:27.1196777Z 	at java.lang.Thread.run(Thread.java:748)
2020-06-15T19:48:27.1196863Z 
2020-06-15T19:48:27.1197553Z 2020-06-15 19:43:26,924 ERROR [io.qua.run.Application] (main) Error running Quarkus application: java.lang.RuntimeException: Failed to start quarkus
2020-06-15T19:48:27.1197716Z 	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:519)
2020-06-15T19:48:27.1197861Z 	at io.quarkus.runtime.Application.start(Application.java:90)
2020-06-15T19:48:27.1197996Z 	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:91)
2020-06-15T19:48:27.1198143Z 	at io.quarkus.runtime.Quarkus.run(Quarkus.java:61)
2020-06-15T19:48:27.1198383Z 	at io.quarkus.runtime.Quarkus.run(Quarkus.java:38)
2020-06-15T19:48:27.1198527Z 	at io.quarkus.runtime.Quarkus.run(Quarkus.java:106)
2020-06-15T19:48:27.1198669Z 	at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
2020-06-15T19:48:27.1198807Z 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2020-06-15T19:48:27.1198960Z 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2020-06-15T19:48:27.1199349Z 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2020-06-15T19:48:27.1199534Z 	at java.lang.reflect.Method.invoke(Method.java:498)
2020-06-15T19:48:27.1199797Z 	at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:31)
2020-06-15T19:48:27.1199983Z 	at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:18)
2020-06-15T19:48:27.1200892Z Caused by: java.lang.RuntimeException: Unable to start HTTP server
2020-06-15T19:48:27.1201264Z 	at io.quarkus.vertx.http.runtime.VertxHttpRecorder.doServerStart(VertxHttpRecorder.java:432)
2020-06-15T19:48:27.1201462Z 	at io.quarkus.vertx.http.runtime.VertxHttpRecorder.startServer(VertxHttpRecorder.java:198)
2020-06-15T19:48:27.1202086Z 	at io.quarkus.deployment.steps.VertxHttpProcessor$openSocket-2064782366.deploy_0(VertxHttpProcessor$openSocket-2064782366.zig:119)
2020-06-15T19:48:27.1207094Z 	at io.quarkus.deployment.steps.VertxHttpProcessor$openSocket-2064782366.deploy(VertxHttpProcessor$openSocket-2064782366.zig:36)
2020-06-15T19:48:27.1211145Z 	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:450)
2020-06-15T19:48:27.1211466Z 	... 12 more
2020-06-15T19:48:27.1225766Z Caused by: java.util.concurrent.ExecutionException: java.lang.LinkageError: loader (instance of  io/quarkus/bootstrap/runner/RunnerClassLoader): attempted  duplicate class definition for name: "io/vertx/core/net/impl/VertxEventLoopGroup"
2020-06-15T19:48:27.1226700Z 	at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
2020-06-15T19:48:27.1229932Z 	at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1908)
2020-06-15T19:48:27.1234288Z 	at io.quarkus.vertx.http.runtime.VertxHttpRecorder.doServerStart(VertxHttpRecorder.java:403)
2020-06-15T19:48:27.1234791Z 	... 16 more
2020-06-15T19:48:27.1246042Z Caused by: java.lang.LinkageError: loader (instance of  io/quarkus/bootstrap/runner/RunnerClassLoader): attempted  duplicate class definition for name: "io/vertx/core/net/impl/VertxEventLoopGroup"
2020-06-15T19:48:27.1248677Z 	at java.lang.ClassLoader.defineClass1(Native Method)
2020-06-15T19:48:27.1252637Z 	at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
2020-06-15T19:48:27.1260807Z 	at io.quarkus.bootstrap.runner.RunnerClassLoader.loadClass(RunnerClassLoader.java:79)
2020-06-15T19:48:27.1266657Z 	at io.quarkus.bootstrap.runner.RunnerClassLoader.loadClass(RunnerClassLoader.java:44)
2020-06-15T19:48:27.1270904Z 	at io.vertx.core.http.impl.HttpServerImpl.<init>(HttpServerImpl.java:67)
2020-06-15T19:48:27.1272893Z 	at io.vertx.core.impl.VertxImpl.createHttpServer(VertxImpl.java:310)
2020-06-15T19:48:27.1279301Z 	at io.quarkus.vertx.http.runtime.VertxHttpRecorder$WebDeploymentVerticle.start(VertxHttpRecorder.java:759)
2020-06-15T19:48:27.1282013Z 	at io.vertx.core.Verticle.start(Verticle.java:66)
2020-06-15T19:48:27.1286941Z 	at io.vertx.core.impl.DeploymentManager.lambda$doDeploy$9(DeploymentManager.java:556)
2020-06-15T19:48:27.1290827Z 	at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:366)
2020-06-15T19:48:27.1296581Z 	at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38)
2020-06-15T19:48:27.1300959Z 	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
2020-06-15T19:48:27.1307695Z 	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
2020-06-15T19:48:27.1310727Z 	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
2020-06-15T19:48:27.1316178Z 	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
2020-06-15T19:48:27.1326888Z 	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
2020-06-15T19:48:27.1336413Z 	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
2020-06-15T19:48:27.1336912Z 	at java.lang.Thread.run(Thread.java:748)
2020-06-15T19:48:27.1337221Z 
2020-06-15T19:48:27.1337468Z 
2020-06-15T19:48:27.1341616Z ####### LOG DUMP ON FAILURE (end) ######
```

I haven't yet had a chance to analyze this log, so creating an issue to keep track of this.

[1] https://github.com/quarkusio/quarkus/pull/10026/checks?check_run_id=773794492


Changed files:
independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/RunnerClassLoader.java

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 921c41088b7..d6bf167acdb 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("");