From 89c27e8e8ab0e0d094ac94ff35c6987b5b11cd7d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 27 Sep 2023 16:01:23 +0200 Subject: [server] Fix deadlock --- .../main/java/org/openslx/bwlp/sat/thrift/cache/CacheBase.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/cache/CacheBase.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/cache/CacheBase.java index 8b549800..ffc92d4e 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/cache/CacheBase.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/cache/CacheBase.java @@ -6,8 +6,6 @@ import java.util.concurrent.TimeUnit; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.thrift.TException; -import org.openslx.util.QuickTimer; -import org.openslx.util.QuickTimer.Task; /** * Class that caches an instance of a given class for 10 minutes. @@ -49,9 +47,11 @@ public abstract class CacheBase { if (doFetch) { // This invocation found latch == null, which means it is // responsible for triggering the actual update. - QuickTimer.scheduleOnce(new Task() { + // Do not use QuickTimer, as we might already be running in it + // and would only deadlock ourselves + new Thread(getClass().getSimpleName() + "-Update") { @Override - public void fire() { + public void run() { T freshInstance = null; try { freshInstance = getCallback(); @@ -68,7 +68,7 @@ public abstract class CacheBase { localLatch.countDown(); } } - }); + }.start(); } // Now just wait for latch, regardless of whether we triggered the update or not boolean ok = false; -- cgit v1.2.3-55-g7522