From 2bd4e11dd8d8a2f7c366a2d2b730117711e1c481 Mon Sep 17 00:00:00 2001 From: Jan Gustafsson Date: Sun, 16 Jun 2024 22:13:54 +0200 Subject: [PATCH] [tellstick] Fix NPE (#16869) (#16882) Signed-off-by: Jan Gustafsson --- .../tellstick/internal/local/TelldusLocalBridgeHandler.java | 6 +++--- .../internal/local/TelldusLocalDeviceController.java | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalBridgeHandler.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalBridgeHandler.java index 9dda967ca7..8cf7f35f40 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalBridgeHandler.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalBridgeHandler.java @@ -111,7 +111,7 @@ public class TelldusLocalBridgeHandler extends BaseBridgeHandler implements Tell throws TellstickException, InterruptedException { TellstickLocalDevicesDTO newList = controller .callRestMethod(TelldusLocalDeviceController.HTTP_LOCAL_API_DEVICES, TellstickLocalDevicesDTO.class); - if (newList.getDevices() != null) { + if (newList != null && newList.getDevices() != null) { logger.debug("Device list {}", newList.getDevices()); if (previouslist == null) { for (TellstickLocalDeviceDTO device : newList.getDevices()) { @@ -167,8 +167,8 @@ public class TelldusLocalBridgeHandler extends BaseBridgeHandler implements Tell throws TellstickException, InterruptedException { TellstickLocalSensorsDTO newList = controller .callRestMethod(TelldusLocalDeviceController.HTTP_LOCAL_API_SENSORS, TellstickLocalSensorsDTO.class); - logger.debug("Updated sensors:{}", newList.getSensors()); - if (newList.getSensors() != null) { + if (newList != null && newList.getSensors() != null) { + logger.debug("Updated sensors:{}", newList.getSensors()); if (previouslist == null) { this.sensorList = newList; for (TellstickLocalSensorDTO sensor : sensorList.getSensors()) { diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalDeviceController.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalDeviceController.java index a9fd1bb7b1..307d20c208 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalDeviceController.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalDeviceController.java @@ -18,6 +18,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.client.api.Request; @@ -249,7 +250,8 @@ public class TelldusLocalDeviceController implements DeviceChangeListener, Senso setLastSend(newDevices.getTimestamp()); } - T callRestMethod(String uri, Class response) throws TelldusLocalException, InterruptedException { + @Nullable T callRestMethod(String uri, Class response) throws TelldusLocalException, InterruptedException { + @Nullable T resultObj = null; try { for (int i = 0; i < MAX_RETRIES; i++) { -- 2.47.3