mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-11 05:41:52 +01:00
Added check for invalid duration (#1209)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
parent
8c4fb060ed
commit
d77d8b763e
@ -43,8 +43,12 @@ public class ExpiringCache<V> {
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user