fix(core): stop leaked executor threads from pinning test classloaders (#2363)

Service beans never shut down their executors. The leftover threads
pinned the classloader of every stopped test application. Around 40
profile restarts per run grew retained heap past the 4GB surefire
default and CI failed with OutOfMemoryError.

Add PreDestroy shutdown to the owning beans. Let the close-drain
scheduler thread time out when idle. Load Groovy parent-first in tests
so its cleaner threads stop pinning app classloaders.
This commit is contained in:
TATSUNO “Taz” Yasuhiro authored and GitHub committed 2026-08-17 22:36:41 -04:00
1 parent 0444753eb8
commit 6962e91020
11 files changed
+91 -7

No files matched your search

@@ -22,6 +22,7 @@ import java.util.Map;
import java.util.Set;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.Mockito.anyList;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
@@ -44,6 +45,25 @@ class AutoScalingReconcilerTest {
assertEquals(2, AutoScalingReconciler.activeCapacity(asg));
}
@Test
void stopTerminatesReconcilerThread() throws Exception {
var asgService = mock(AutoScalingService.class);
var ec2Service = mock(Ec2Service.class);
var elbV2Service = mock(ElbV2Service.class);
var reconciler = new AutoScalingReconciler(asgService, ec2Service, elbV2Service);
var preexisting = Thread.getAllStackTraces().keySet();
reconciler.start();
var reconcilerThread = Thread.getAllStackTraces().keySet().stream()
.filter(t -> "asg-reconciler".equals(t.getName()) && !preexisting.contains(t))
.findFirst().orElseThrow();
reconciler.stop();
reconcilerThread.join(5_000);
assertFalse(reconcilerThread.isAlive());
}
@Test
void reconcileCompletesSettledInstanceRefreshes() {
AutoScalingService asgService = mock(AutoScalingService.class);