Skip to content

Commit ea41cd5

Browse files
Copilotslachiewicz
andcommitted
Fix ThreadLocal memory leak in ParallelScatterZipCreator usage
Co-authored-by: slachiewicz <[email protected]>
1 parent a0c4a50 commit ea41cd5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ public Thread newThread(Runnable r) {
4646
return thread;
4747
}
4848
};
49-
return new ThreadPoolExecutor(1, poolSize, 1L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), threadFactory);
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;
5055
}
5156
}

0 commit comments

Comments
 (0)