From: Niki Roo Date: Fri, 1 May 2020 11:17:39 +0000 (+0200) Subject: CacheLib: better lock X-Git-Tag: fanfix-swing-1.1.0~24 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=30a7de374c944fe797424424e0355d286ee845e6;p=fanfix-swing.git CacheLib: better lock --- diff --git a/src/be/nikiroo/fanfix/library/CacheLibrary.java b/src/be/nikiroo/fanfix/library/CacheLibrary.java index 92e4ae7a..a3c3b5e3 100644 --- a/src/be/nikiroo/fanfix/library/CacheLibrary.java +++ b/src/be/nikiroo/fanfix/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());