Skip to content

Commit bb9d08f

Browse files
Copilotslachiewicz
andcommitted
Use fixed thread pool size to limit ThreadLocal instances
Co-authored-by: slachiewicz <[email protected]>
1 parent 099dd45 commit bb9d08f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/main/java/org/codehaus/plexus/archiver/zip/ConcurrentJarCreatorExecutorServiceFactory.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ public Thread newThread(Runnable r) {
4646
return thread;
4747
}
4848
};
49-
ThreadPoolExecutor executor = new ThreadPoolExecutor(
50-
1, poolSize, 1L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), threadFactory);
51-
// Allow core threads to time out quickly to prevent ThreadLocal memory leaks
52-
// from Apache Commons Compress ParallelScatterZipCreator
53-
executor.allowCoreThreadTimeOut(true);
54-
return executor;
49+
// Use poolSize as both core and max to prevent thread growth
50+
// This limits the number of concurrent threads and associated ThreadLocal instances
51+
return new ThreadPoolExecutor(
52+
poolSize, poolSize, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), threadFactory);
5553
}
5654
}

0 commit comments

Comments
 (0)