Skip to content

Commit 7e5d79f

Browse files
aksOpsclaude
andcommitted
fix: remove shutdownNow() that caused RejectedExecutionException cascade
shutdownNow() was called at the end of each analysis path to prevent auto-close from hanging on stuck ANTLR threads. But it immediately rejected all subsequent batch submissions, causing every file to be skipped with RejectedExecutionException. Fix: rely on the 30-second per-file timeout + Future.cancel(true) to handle stuck files. After all futures are collected (completed or cancelled), the try-with-resources auto-close calls shutdown() + awaitTermination() which returns quickly since all tasks are done. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 84654f8 commit 7e5d79f

1 file changed

Lines changed: 0 additions & 18 deletions

File tree

src/main/java/io/github/randomcodespace/iq/analyzer/Analyzer.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ private AnalysisResult runWithCache(Path root, Integer parallelism, AnalysisCach
261261
final int idx = i;
262262
final DiscoveredFile file = files.get(idx);
263263
final AnalysisCache cacheRef = cache;
264-
try {
265264
futures.add(executor.submit(() -> {
266265
// Check cache first
267266
if (cacheRef != null) {
@@ -293,9 +292,6 @@ private AnalysisResult runWithCache(Path root, Integer parallelism, AnalysisCach
293292
}
294293
return null;
295294
}));
296-
} catch (java.util.concurrent.RejectedExecutionException e) {
297-
log.warn("Executor rejected task for {}, skipping", file.path());
298-
}
299295
}
300296

301297
// Collect in order -- deterministic regardless of thread completion order
@@ -312,8 +308,6 @@ private AnalysisResult runWithCache(Path root, Integer parallelism, AnalysisCach
312308
log.warn("Analysis interrupted for {}", files.get(i).path());
313309
}
314310
}
315-
// Force-cancel any stuck threads before auto-close waits for them
316-
executorService.shutdownNow();
317311
}
318312

319313
if (cache != null && cacheHitsCounter.get() > 0) {
@@ -561,7 +555,6 @@ private AnalysisResult runBatchedWithCache(Path root, Integer parallelism, int b
561555
for (int i = 0; i < batch.size(); i++) {
562556
final int idx = i;
563557
final DiscoveredFile file = batch.get(idx);
564-
try {
565558
futures.add(batchExecutorService.submit(() -> {
566559
if (incremental) {
567560
try {
@@ -590,9 +583,6 @@ private AnalysisResult runBatchedWithCache(Path root, Integer parallelism, int b
590583
}
591584
return null;
592585
}));
593-
} catch (java.util.concurrent.RejectedExecutionException e) {
594-
log.warn("Executor rejected task for {}, skipping", file.path());
595-
}
596586
}
597587

598588
// Collect in order
@@ -663,8 +653,6 @@ private AnalysisResult runBatchedWithCache(Path root, Integer parallelism, int b
663653
batch.clear();
664654
}
665655
}
666-
// Force-cancel any stuck threads before auto-close waits for them
667-
batchExecutorService.shutdownNow();
668656
}
669657

670658
if (cacheHits > 0) {
@@ -938,7 +926,6 @@ private int[] processSmartBatch(
938926
for (int i = 0; i < batch.size(); i++) {
939927
final int idx = i;
940928
final DiscoveredFile file = batch.get(idx);
941-
try {
942929
futures.add(executor.submit(() -> {
943930
if (incremental) {
944931
try {
@@ -967,9 +954,6 @@ private int[] processSmartBatch(
967954
}
968955
return null;
969956
}));
970-
} catch (java.util.concurrent.RejectedExecutionException e) {
971-
log.warn("Executor rejected task for {}, skipping", file.path());
972-
}
973957
}
974958

975959
for (int i = 0; i < futures.size(); i++) {
@@ -1016,8 +1000,6 @@ private int[] processSmartBatch(
10161000
nodes += result.nodes().size();
10171001
edges += result.edges().size();
10181002
}
1019-
// Force-cancel any stuck threads before auto-close waits for them
1020-
executor.shutdownNow();
10211003
}
10221004

10231005
if (!incremental && (!batchNodes.isEmpty() || !batchEdges.isEmpty())) {

0 commit comments

Comments
 (0)