Skip to content

Commit 84654f8

Browse files
aksOpsclaude
andcommitted
fix: handle RejectedExecutionException in all analysis submit paths
After shutdownNow() cancels stuck threads, subsequent executor.submit() calls throw RejectedExecutionException. This crashed the batch processing loop instead of gracefully skipping the rejected files. Fix: wrap all 3 executor.submit() call sites (run, runIndex, processSmartBatch) with try/catch for RejectedExecutionException — log warning and skip file. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 4a5b31b commit 84654f8

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ 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 {
264265
futures.add(executor.submit(() -> {
265266
// Check cache first
266267
if (cacheRef != null) {
@@ -292,6 +293,9 @@ private AnalysisResult runWithCache(Path root, Integer parallelism, AnalysisCach
292293
}
293294
return null;
294295
}));
296+
} catch (java.util.concurrent.RejectedExecutionException e) {
297+
log.warn("Executor rejected task for {}, skipping", file.path());
298+
}
295299
}
296300

297301
// Collect in order -- deterministic regardless of thread completion order
@@ -557,6 +561,7 @@ private AnalysisResult runBatchedWithCache(Path root, Integer parallelism, int b
557561
for (int i = 0; i < batch.size(); i++) {
558562
final int idx = i;
559563
final DiscoveredFile file = batch.get(idx);
564+
try {
560565
futures.add(batchExecutorService.submit(() -> {
561566
if (incremental) {
562567
try {
@@ -585,6 +590,9 @@ private AnalysisResult runBatchedWithCache(Path root, Integer parallelism, int b
585590
}
586591
return null;
587592
}));
593+
} catch (java.util.concurrent.RejectedExecutionException e) {
594+
log.warn("Executor rejected task for {}, skipping", file.path());
595+
}
588596
}
589597

590598
// Collect in order
@@ -930,6 +938,7 @@ private int[] processSmartBatch(
930938
for (int i = 0; i < batch.size(); i++) {
931939
final int idx = i;
932940
final DiscoveredFile file = batch.get(idx);
941+
try {
933942
futures.add(executor.submit(() -> {
934943
if (incremental) {
935944
try {
@@ -958,6 +967,9 @@ private int[] processSmartBatch(
958967
}
959968
return null;
960969
}));
970+
} catch (java.util.concurrent.RejectedExecutionException e) {
971+
log.warn("Executor rejected task for {}, skipping", file.path());
972+
}
961973
}
962974

963975
for (int i = 0; i < futures.size(); i++) {

0 commit comments

Comments
 (0)