test(apigateway): await authorizer cleanup tasks (#4261)

Use try-with-resources for the two authorizer test cleanup executors so close() waits for every submitted delete, including when an earlier Future.get fails.

Closes #3999
This commit is contained in:
Aniket Shukla authored and GitHub committed 2026-09-23 18:15:43 -04:00
1 parent fab5130ebb
commit ed627a6ce7
2 files changed
+2 -8

No files matched your search

@@ -1033,8 +1033,7 @@ class ApiGatewayRequestAuthorizerIntegrationTest {
}
private static void deleteFunctions(String... functionNames) throws Exception {
ExecutorService executor = Executors.newFixedThreadPool(functionNames.length);
try {
try (ExecutorService executor = Executors.newFixedThreadPool(functionNames.length)) {
List<Future<?>> deletions = new ArrayList<>();
for (String functionName : functionNames) {
deletions.add(executor.submit(() -> deleteFunction(functionName)));
@@ -1042,8 +1041,6 @@ class ApiGatewayRequestAuthorizerIntegrationTest {
for (Future<?> deletion : deletions) {
deletion.get();
}
} finally {
executor.shutdown();
}
}
@@ -746,8 +746,7 @@ class HttpApiRequestAuthorizerTest {
}
private static void deleteFunctions(String... functionNames) throws Exception {
ExecutorService executor = Executors.newFixedThreadPool(functionNames.length);
try {
try (ExecutorService executor = Executors.newFixedThreadPool(functionNames.length)) {
List<Future<?>> deletions = new ArrayList<>();
for (String functionName : functionNames) {
deletions.add(executor.submit(() -> deleteFunction(functionName)));
@@ -755,8 +754,6 @@ class HttpApiRequestAuthorizerTest {
for (Future<?> deletion : deletions) {
deletion.get();
}
} finally {
executor.shutdown();
}
}