From: Niki Roo Date: Fri, 1 May 2020 11:17:39 +0000 (+0200) Subject: CacheLib: better lock X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=2b5784f2657e0e7b8ddf2ce5563581e6ac21ab75;p=nikiroo-utils.git CacheLib: better lock --- diff --git a/library/CacheLibrary.java b/library/CacheLibrary.java index 92e4ae7..a3c3b5e 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());