Skip to content

Commit

Permalink
Fix QuarkusClassLoader leak in QuarkusProdModeTest
Browse files Browse the repository at this point in the history
This could result in the tests either hanging or the
process dying because of insufficient metaspace
  • Loading branch information
geoand committed Jun 16, 2021
1 parent 255ff06 commit 9553d79
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 9553d79

Please sign in to comment.