From 8a3baf80036bc0ab3c85aa8b09dc02b9c5f30bc5 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Sat, 4 Jan 2025 19:59:11 +0100 Subject: [PATCH] Fix NullPointerException (#18034) Signed-off-by: Jacob Laursen --- .../enocean/internal/handler/EnOceanBaseSensorHandler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/handler/EnOceanBaseSensorHandler.java b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/handler/EnOceanBaseSensorHandler.java index 27a035c51a2..841ffc76a6a 100644 --- a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/handler/EnOceanBaseSensorHandler.java +++ b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/handler/EnOceanBaseSensorHandler.java @@ -18,6 +18,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.Hashtable; +import java.util.Objects; import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; @@ -87,7 +88,7 @@ public class EnOceanBaseSensorHandler extends EnOceanBaseThingHandler implements config.receivingEEPId.forEach(receivingEEP -> { EEPType receivingEEPType = EEPType.getType(receivingEEP); EEPType existingKey = receivingEEPTypes.putIfAbsent(receivingEEPType.getRORG(), receivingEEPType); - if (existingKey != null) { + if (!Objects.isNull(existingKey)) { throw new IllegalArgumentException("Receiving more than one EEP of the same RORG is not supported"); } }); @@ -155,6 +156,9 @@ public class EnOceanBaseSensorHandler extends EnOceanBaseThingHandler implements ERP1Message msg = (ERP1Message) packet; EEPType localReceivingType = receivingEEPTypes.get(msg.getRORG()); + if (Objects.isNull(localReceivingType)) { + return; + } EEP eep = EEPFactory.buildEEP(localReceivingType, (ERP1Message) packet); logger.debug("ESP Packet payload {} for {} received", HexUtils.bytesToHex(packet.getPayload()),