Skip to content

Commit

Permalink
Merge pull request #17956 from geoand/prod-mode-test-leak
Browse files Browse the repository at this point in the history
Fix QuarkusClassLoader leak in QuarkusProdModeTest
  • Loading branch information
Sanne authored Jun 16, 2021
2 parents f2b5115 + 9553d79 commit 7e3fea5
Showing 1 changed file with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,20 +312,7 @@ public void beforeAll(ExtensionContext extensionContext) throws Exception {
originalHandlers = rootLogger.getHandlers();
rootLogger.addHandler(inMemoryLogHandler);

timeoutTask = new TimerTask() {
@Override
public void run() {
System.err.println("Test has been running for more than 5 minutes, thread dump is:");
for (Map.Entry<Thread, StackTraceElement[]> i : Thread.getAllStackTraces().entrySet()) {
System.err.println("\n");
System.err.println(i.toString());
System.err.println("\n");
for (StackTraceElement j : i.getValue()) {
System.err.println(j);
}
}
}
};
timeoutTask = new PrintStackTraceTimerTask();
timeoutTimer.schedule(timeoutTask, 1000 * 60 * 5);

ExtensionContext.Store store = extensionContext.getRoot().getStore(ExtensionContext.Namespace.GLOBAL);
Expand Down Expand Up @@ -638,6 +625,7 @@ public void afterAll(ExtensionContext extensionContext) throws Exception {
try {
if (curatedApplication != null) {
curatedApplication.close();
curatedApplication = null;
}
} finally {
timeoutTask.cancel();
Expand Down Expand Up @@ -699,4 +687,18 @@ public QuarkusProdModeTest setCommandLineParameters(String... commandLineParamet
return this;
}

private static class PrintStackTraceTimerTask extends TimerTask {
@Override
public void run() {
System.err.println("Test has been running for more than 5 minutes, thread dump is:");
for (Map.Entry<Thread, StackTraceElement[]> i : Thread.getAllStackTraces().entrySet()) {
System.err.println("\n");
System.err.println(i.toString());
System.err.println("\n");
for (StackTraceElement j : i.getValue()) {
System.err.println(j);
}
}
}
}
}

0 comments on commit 7e3fea5

Please sign in to comment.