From 0a5a9912a53f9dcf49ac336ec3e52731dd0d6790 Mon Sep 17 00:00:00 2001 From: lsiepel Date: Sat, 4 Nov 2023 10:29:43 +0100 Subject: [PATCH] null check (#15841) Signed-off-by: Leo Siepel --- .../discovery/internal/BluetoothDiscoveryService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/discovery/internal/BluetoothDiscoveryService.java b/bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/discovery/internal/BluetoothDiscoveryService.java index 85c530b33..ccdf31874 100644 --- a/bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/discovery/internal/BluetoothDiscoveryService.java +++ b/bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/discovery/internal/BluetoothDiscoveryService.java @@ -16,6 +16,7 @@ import java.time.Duration; import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; @@ -152,10 +153,9 @@ public class BluetoothDiscoveryService extends AbstractDiscoveryService implemen public void deviceDiscovered(BluetoothDevice device) { logger.debug("Discovered bluetooth device '{}': {}", device.getName(), device); - DiscoveryCache cache = discoveryCaches.computeIfAbsent(device.getAddress(), addr -> new DiscoveryCache()); - if (cache != null) { - cache.handleDiscovery(device); - } + DiscoveryCache cache = Objects + .requireNonNull(discoveryCaches.computeIfAbsent(device.getAddress(), addr -> new DiscoveryCache())); + cache.handleDiscovery(device); } private static ThingUID createThingUIDWithBridge(DiscoveryResult result, BluetoothAdapter adapter) {