diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/cache/ExpiringCache.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/cache/ExpiringCache.java index 381dcf44b..29838af5e 100755 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/cache/ExpiringCache.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/cache/ExpiringCache.java @@ -43,8 +43,12 @@ public class ExpiringCache { * * @param expiry the duration for how long the value stays valid * @param action the action to retrieve/calculate the value + * @throws IllegalArgumentException For an expire value <=0. */ public ExpiringCache(Duration expiry, Supplier<@Nullable V> action) { + if (expiry.isNegative() || expiry.isZero()) { + throw new IllegalArgumentException("Cache expire time must be greater than 0"); + } this.expiry = expiry.toNanos(); this.action = action; }