From 54b5a6ca6c8ad61a48e98b58998be77f704d3e32 Mon Sep 17 00:00:00 2001 From: Sheepit Renderfarm Date: Fri, 13 Dec 2024 13:09:20 +0100 Subject: [PATCH] Fix: race condition on shutdown of zip extractor --- src/main/java/com/sheepit/client/UnzipUtils.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/sheepit/client/UnzipUtils.java b/src/main/java/com/sheepit/client/UnzipUtils.java index 69a5b51..1a4b94b 100644 --- a/src/main/java/com/sheepit/client/UnzipUtils.java +++ b/src/main/java/com/sheepit/client/UnzipUtils.java @@ -245,6 +245,17 @@ public class UnzipUtils { private static void writeWait(WriteQueue queue, ExecutorService executor) throws InterruptedException { queue.doneAdding = true; executor.shutdown(); + + try { + if (executor.awaitTermination(60, TimeUnit.MINUTES) == false) { + executor.shutdownNow(); + } + } + catch (InterruptedException e) { + executor.shutdownNow(); + Thread.currentThread().interrupt(); + } + //Encourage the JVM to release memory used while decompressing GC_RUNNER.execute(System::gc); }