From d8d76c00c77ac344fbeed1bbc044ac59cde7e406 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Mon, 8 May 2023 09:25:40 -0400 Subject: [PATCH] Hotfix for another potential race condition --- .../modernfix/resources/PackResourcesCacheEngine.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/org/embeddedt/modernfix/resources/PackResourcesCacheEngine.java b/common/src/main/java/org/embeddedt/modernfix/resources/PackResourcesCacheEngine.java index d02c55d8..577e1c50 100644 --- a/common/src/main/java/org/embeddedt/modernfix/resources/PackResourcesCacheEngine.java +++ b/common/src/main/java/org/embeddedt/modernfix/resources/PackResourcesCacheEngine.java @@ -31,7 +31,7 @@ public class PackResourcesCacheEngine { private final Map> namespacesByType; private final Set containedPaths; private final EnumMap>> resourceListings; - private CompletableFuture cacheFuture; + private volatile CompletableFuture cacheFuture; public PackResourcesCacheEngine(Function> namespacesRetriever, BiFunction basePathRetriever) { this.namespacesByType = new EnumMap<>(PackType.class); @@ -114,8 +114,12 @@ public class PackResourcesCacheEngine { private void awaitLoad() { if(this.cacheFuture != null) { - this.cacheFuture.join(); - this.cacheFuture = null; + synchronized (this) { + if(this.cacheFuture != null) { + this.cacheFuture.join(); + this.cacheFuture = null; + } + } } }