Close ApplicationContext after test AOT processing

See commit 1c108054ee
Closes gh-34841
This commit is contained in:
Sam Brannen
2025-05-01 10:50:38 +02:00
parent 4466548f53
commit b943817f3e
2 changed files with 61 additions and 6 deletions
@@ -314,8 +314,7 @@ public class TestContextAotGenerator {
ClassName processAheadOfTime(MergedContextConfiguration mergedConfig,
GenerationContext generationContext) throws TestContextAotException {
GenericApplicationContext gac = loadContextForAotProcessing(mergedConfig);
try {
try (GenericApplicationContext gac = loadContextForAotProcessing(mergedConfig)) {
return this.aotGenerator.processAheadOfTime(gac, generationContext);
}
catch (Throwable ex) {
@@ -333,7 +332,7 @@ public class TestContextAotGenerator {
* context or if one of the prerequisites is not met
* @see AotContextLoader#loadContextForAotProcessing(MergedContextConfiguration, RuntimeHints)
*/
private GenericApplicationContext loadContextForAotProcessing(
GenericApplicationContext loadContextForAotProcessing(
MergedContextConfiguration mergedConfig) throws TestContextAotException {
Class<?> testClass = mergedConfig.getTestClass();