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..b933f297da7 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 @@ -172,8 +172,8 @@ public ValueCacheImpl(String scriptIdentifier) { } @Override - public Object get(String key, Supplier supplier) { - return Objects.requireNonNull(cache.computeIfAbsent(key, k -> supplier.get())); + public @Nullable Object get(String key, Supplier supplier) { + return cache.computeIfAbsent(key, k -> supplier.get()); } private Collection values() { @@ -231,11 +231,11 @@ public TrackingValueCacheImpl(String scriptIdentifier) { } @Override - public Object get(String key, Supplier supplier) { + public @Nullable 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); }