diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedDevModeMain.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedDevModeMain.java index 91730e752972c..b68f3b9bbc676 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedDevModeMain.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedDevModeMain.java @@ -311,6 +311,7 @@ public void close() { restarting = true; if (codeGenWatcher != null) { codeGenWatcher.shutdown(); + codeGenWatcher = null; } for (int i = listeners.size() - 1; i >= 0; i--) { @@ -320,6 +321,7 @@ public void close() { log.warn("Unable to invoke 'beforeShutdown' of " + listeners.get(i).getClass(), e); } } + listeners.clear(); try { stop(); @@ -341,10 +343,13 @@ public void close() { for (HotReplacementSetup i : hotReplacementSetups) { i.close(); } + hotReplacementSetups.clear(); } finally { try { DevConsoleManager.close(); curatedApplication.close(); + curatedApplication = null; + augmentAction = null; } finally { if (shutdownThread != null) { try { @@ -401,29 +406,7 @@ public void run() { } augmentAction = new AugmentActionImpl(curatedApplication, - List.of(new Consumer() { - @Override - public void accept(BuildChainBuilder buildChainBuilder) { - buildChainBuilder.addBuildStep(new BuildStep() { - @Override - public void execute(BuildContext context) { - //we need to make sure all hot reloadable classes are application classes - context.produce(new ApplicationClassPredicateBuildItem(new Predicate() { - @Override - public boolean test(String s) { - QuarkusClassLoader cl = (QuarkusClassLoader) Thread.currentThread() - .getContextClassLoader(); - String resourceName = ClassloadHelper.fromClassNameToResourceName(s); - //if the class file is present in this (and not the parent) CL then it is an application class - List res = cl - .getElementsWithResource(resourceName, true); - return !res.isEmpty(); - } - })); - } - }).produces(ApplicationClassPredicateBuildItem.class).build(); - } - }), + List.of(new AddApplicationClassPredicateBuildStep()), List.of()); // code generators should be initialized before the runtime compilation is setup to properly configure the sources directories @@ -475,4 +458,29 @@ public void run() { throw toThrow; } } + + private static class AddApplicationClassPredicateBuildStep implements Consumer { + + @Override + public void accept(BuildChainBuilder buildChainBuilder) { + buildChainBuilder.addBuildStep(new BuildStep() { + @Override + public void execute(BuildContext context) { + //we need to make sure all hot reloadable classes are application classes + context.produce(new ApplicationClassPredicateBuildItem(new Predicate() { + @Override + public boolean test(String s) { + QuarkusClassLoader cl = (QuarkusClassLoader) Thread.currentThread() + .getContextClassLoader(); + String resourceName = ClassloadHelper.fromClassNameToResourceName(s); + //if the class file is present in this (and not the parent) CL then it is an application class + List res = cl + .getElementsWithResource(resourceName, true); + return !res.isEmpty(); + } + })); + } + }).produces(ApplicationClassPredicateBuildItem.class).build(); + } + } }