diff --git a/source/net/filebot/Cache.java b/source/net/filebot/Cache.java index 835032cc..76cd89aa 100644 --- a/source/net/filebot/Cache.java +++ b/source/net/filebot/Cache.java @@ -63,7 +63,7 @@ public class Cache { Element element = null; try { element = cache.get(key); - if (!condition.test(element)) { + if (element != null && !condition.test(element)) { return getElementValue(element); } } catch (Exception e) { @@ -77,7 +77,7 @@ public class Cache { } public Object computeIfAbsent(Object key, Compute compute) throws Exception { - return computeIf(key, isAbsent(), compute); + return computeIf(key, it -> it == null, compute); } public void put(Object key, Object value) { @@ -112,12 +112,8 @@ public class Cache { } } - public static Predicate isAbsent() { - return (element) -> element == null; - } - public static Predicate isStale(Duration expirationTime) { - return (element) -> element == null || element.getObjectValue() == null || System.currentTimeMillis() - element.getLatestOfCreationAndUpdateTime() < expirationTime.toMillis(); + return (element) -> System.currentTimeMillis() - element.getLatestOfCreationAndUpdateTime() > expirationTime.toMillis(); } @FunctionalInterface diff --git a/source/net/filebot/web/ID3Lookup.java b/source/net/filebot/web/ID3Lookup.java index 5162319d..60fd842e 100644 --- a/source/net/filebot/web/ID3Lookup.java +++ b/source/net/filebot/web/ID3Lookup.java @@ -9,7 +9,6 @@ import java.io.File; import java.util.Collection; import java.util.LinkedHashMap; import java.util.Map; -import java.util.logging.Level; import javax.swing.Icon;