Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up IsolatedDevModeMain when closing a bit more #41591

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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--) {
Expand All @@ -320,6 +321,7 @@ public void close() {
log.warn("Unable to invoke 'beforeShutdown' of " + listeners.get(i).getClass(), e);
}
}
listeners.clear();

try {
stop();
Expand All @@ -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 {
Expand Down Expand Up @@ -401,29 +406,7 @@ public void run() {
}

augmentAction = new AugmentActionImpl(curatedApplication,
List.of(new Consumer<BuildChainBuilder>() {
@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<String>() {
@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<ClassPathElement> 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
Expand Down Expand Up @@ -475,4 +458,29 @@ public void run() {
throw toThrow;
}
}

private static class AddApplicationClassPredicateBuildStep implements Consumer<BuildChainBuilder> {

@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<String>() {
@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<ClassPathElement> res = cl
.getElementsWithResource(resourceName, true);
return !res.isEmpty();
}
}));
}
}).produces(ApplicationClassPredicateBuildItem.class).build();
}
}
}
Loading