diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/CacheScriptExtension.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/CacheScriptExtension.java index f9358c42a34..d9c2f2d2c10 100644 --- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/CacheScriptExtension.java +++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/CacheScriptExtension.java @@ -173,7 +173,7 @@ public ValueCacheImpl(String scriptIdentifier) { @Override public Object get(String key, Supplier supplier) { - return Objects.requireNonNull(cache.computeIfAbsent(key, k -> supplier.get())); + return cache.computeIfAbsent(key, k -> supplier.get()); } private Collection values() { @@ -235,7 +235,7 @@ public Object get(String key, Supplier supplier) { cacheLock.lock(); try { rememberAccessToKey(key); - Object value = Objects.requireNonNull(sharedCache.computeIfAbsent(key, k -> supplier.get())); + Object value = sharedCache.computeIfAbsent(key, k -> supplier.get()); logger.trace("GET with supplier to cache from '{}': '{}' -> '{}'", scriptIdentifier, key, value); return value; diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ValueCache.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ValueCache.java index d736eb56353..a84a67374f7 100644 --- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ValueCache.java +++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ValueCache.java @@ -58,8 +58,9 @@ public interface ValueCache { * Get a value from the cache or create a new key-value-pair from the given supplier * * @param key the key of the requested value - * @param supplier a supplier that returns a non-null value to be used if the key was not present + * @param supplier a supplier that returns a value to be used if the key was not present * @return the value associated with the key */ + @Nullable Object get(String key, Supplier supplier); }