From 2b5784f2657e0e7b8ddf2ce5563581e6ac21ab75 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Fri, 1 May 2020 13:17:39 +0200 Subject: [PATCH] CacheLib: better lock --- library/CacheLibrary.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/library/CacheLibrary.java b/library/CacheLibrary.java index 92e4ae7a..a3c3b5e3 100644 --- a/library/CacheLibrary.java +++ b/library/CacheLibrary.java @@ -67,6 +67,7 @@ public class CacheLibrary extends BasicLibrary { pg = new Progress(); } + List copy; synchronized (metasLock) { // We make sure that cached metas have precedence if (metasMixed == null) { @@ -86,10 +87,12 @@ public class CacheLibrary extends BasicLibrary { } } } + + copy = new ArrayList(metasMixed); } pg.done(); - return new ArrayList(metasMixed); + return copy; } @Override @@ -404,9 +407,7 @@ public class CacheLibrary extends BasicLibrary { MetaData meta = lib.imprt(url, pgImprt); updateMetaCache(metasReal, meta); - synchronized (metasLock) { - metasMixed = null; - } + metasMixed = null; clearFromCache(meta.getLuid()); -- 2.27.0