Skip to content

Commit

Permalink
Merge pull request #44638 from geoand/#44117
Browse files Browse the repository at this point in the history
Clean up effects of test profiles when @QuarkusMainTest completes
  • Loading branch information
geoand authored Nov 25, 2024
2 parents 192a870 + 71804eb commit 9361824
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class QuarkusMainTestExtension extends AbstractJvmQuarkusTestExtension
AfterAllCallback, ExecutionCondition {

PrepareResult prepareResult;
LinkedBlockingDeque<Runnable> shutdownTasks;

/**
* The result from an {@link Launch} test
Expand Down Expand Up @@ -79,9 +80,8 @@ private void ensurePrepared(ExtensionContext extensionContext, Class<? extends Q
prepareResult = null;
}
if (prepareResult == null) {
final LinkedBlockingDeque<Runnable> shutdownTasks = new LinkedBlockingDeque<>();
PrepareResult result = createAugmentor(extensionContext, profile, shutdownTasks);
prepareResult = result;
shutdownTasks = new LinkedBlockingDeque<>();
prepareResult = createAugmentor(extensionContext, profile, shutdownTasks);
}
}

Expand Down Expand Up @@ -318,6 +318,17 @@ private boolean isIntegrationTest(Class<?> clazz) {
@Override
public void afterAll(ExtensionContext context) throws Exception {
currentTestClassStack.pop();

try {
if (shutdownTasks != null) {
for (Runnable shutdownTask : shutdownTasks) {
shutdownTask.run();
}
}
shutdownTasks = null;
} catch (Exception e) {
System.err.println("Unable to run shutdown tasks: " + e.getMessage());
}
}

@Override
Expand Down

0 comments on commit 9361824

Please sign in to comment.