From bd664ff0c89631e23a9506e0fea9d78bf5f3f419 Mon Sep 17 00:00:00 2001 From: J-N-K Date: Sat, 31 Oct 2020 00:29:03 +0100 Subject: [PATCH] [infrastructure] add external null-annotations (#8848) Signed-off-by: Jan N. Klug --- .../internal/json/AirQualityJsonCity.java | 5 +- .../internal/json/AirQualityJsonData.java | 6 +- .../internal/handler/ADBridgeHandler.java | 2 +- .../internal/AccountServlet.java | 5 +- .../discovery/SmartHomeDevicesDiscovery.java | 4 +- .../handler/SmartHomeDeviceHandler.java | 3 +- .../handler/AmbientWeatherBridgeHandler.java | 15 +- .../internal/processor/RemoteSensor.java | 2 +- .../AutomowerCommunicationException.java | 6 +- .../bluegiga/internal/eir/EirDataType.java | 6 +- .../bluegiga/internal/eir/EirFlags.java | 6 +- .../internal/RoamingBluetoothDevice.java | 5 +- .../internal/api/SmartherApiConnector.java | 3 +- .../internal/api/dto/Enums.java | 18 +- .../SmartherAuthorizationException.java | 5 +- .../exception/SmartherGatewayException.java | 7 +- .../SmartherInvalidResponseException.java | 3 +- .../internal/util/DateUtil.java | 10 + .../BuienradarParseException.java | 9 +- .../BuienradarPredictionAPI.java | 3 +- .../binding/caddx/internal/CaddxMessage.java | 4 +- .../DarkSkyCommunicationException.java | 7 +- .../DarkSkyConfigurationException.java | 7 +- .../connection/DarkSkyConnection.java | 2 +- .../internal/handler/LightThingHandler.java | 6 +- .../manager/impl/DeviceStatusManagerImpl.java | 31 ++- .../impl/TemperatureControlManager.java | 82 +++--- .../impl/DeviceSensorValue.java | 24 +- .../api/DraytonWiserApiException.java | 5 +- .../device/cosem/CosemObjectFactory.java | 59 +++-- .../discovery/DSMRMeterDiscoveryService.java | 4 +- .../EnturCommunicationException.java | 5 +- .../exec/internal/handler/ExecHandler.java | 3 +- .../fmiweather/internal/client/Client.java | 2 +- .../foobot/internal/FoobotApiException.java | 3 +- .../handler/FoobotAccountHandler.java | 5 +- .../binding/gree/internal/GreeException.java | 8 +- .../internal/discovery/GreeDeviceFinder.java | 2 +- .../handler/HDPowerViewShadeHandler.java | 6 +- .../HeliosPropertiesFormatException.java | 3 +- .../internal/api/HPServerResult.java | 4 +- .../binding/hue/internal/HueBridge.java | 7 +- .../openhab/binding/hue/internal/Scene.java | 3 +- .../manager/DeviceStructureManager.java | 2 +- .../internal/device/CommandHandler.java | 8 +- .../internal/device/MessageHandler.java | 5 +- .../internal/driver/hub/ReadByteBuffer.java | 4 +- .../binding/insteon/internal/message/Msg.java | 8 +- .../binding/km200/internal/KM200Utils.java | 5 +- .../internal/handler/KM200GatewayHandler.java | 16 +- .../internal/handler/KM200ThingHandler.java | 5 +- .../internal/client/AbstractKNXClient.java | 3 +- .../inverter/KostalInverterFactory.java | 7 +- .../connection/ConnectionStateMachine.java | 3 +- .../handler/LGWebOSTVMouseSocket.java | 3 +- .../internal/handler/LGWebOSTVSocket.java | 3 +- .../linky/internal/api/EnedisHttpApi.java | 5 +- .../internal/handler/LogHandler.java | 13 +- .../loxone/internal/LxServerHandler.java | 13 +- .../lutron/internal/xml/DbXmlInfoReader.java | 6 +- .../internal/handler/MeteoAlerteHandler.java | 5 +- .../miio/internal/MiIoCryptoException.java | 5 +- .../miio/internal/cloud/MiCloudException.java | 5 +- .../internal/handler/MiIoAbstractHandler.java | 5 +- .../miio/internal/robot/RRMapFileParser.java | 13 +- .../protocol/MilightV6SessionManager.java | 2 +- .../internal/HeliosEasyControlsHandler.java | 7 +- .../modbus/studer/internal/StuderHandler.java | 55 ++-- .../discovery/SunspecDiscoveryProcess.java | 9 +- .../handler/AbstractSunSpecHandler.java | 4 +- .../handler/MonopriceAudioHandler.java | 15 +- .../mqtt/generic/values/NumberValue.java | 2 + .../nanoleaf/internal/OpenAPIUtils.java | 5 +- .../handler/NanoleafControllerHandler.java | 9 +- .../neeo/internal/net/HttpResponse.java | 4 +- .../handler/AbstractNetatmoThingHandler.java | 10 +- .../connector/CommunicationStatus.java | 5 +- .../nhc1/NikoHomeControlCommunication1.java | 248 ++++++++++-------- .../nhc2/NikoHomeControlCommunication2.java | 25 +- .../internal/ThermostatHandler.java | 2 +- .../binding/onewire/internal/SensorId.java | 5 +- .../internal/discovery/OwDiscoveryItem.java | 4 +- .../AdvancedMultisensorThingHandler.java | 21 +- .../OpenWeatherMapCommunicationException.java | 7 +- .../OpenWeatherMapConfigurationException.java | 7 +- .../connection/OpenWeatherMapConnection.java | 5 +- .../internal/device/PJLinkDevice.java | 5 +- .../internal/handler/PLCCommonHandler.java | 6 +- .../handler/AbstractPlugwiseThingHandler.java | 1 + .../pulseaudio/internal/cli/Parser.java | 7 +- .../RadioThermostatConnector.java | 4 + .../exceptions/RemoteopenhabException.java | 7 +- .../internal/handler/ExpiringMap.java | 2 +- .../service/MediaRendererService.java | 10 +- .../internal/service/ServiceFactory.java | 2 +- .../internal/action/SatelEventLogActions.java | 1 + .../internal/handler/SatelThingHandler.java | 2 +- .../satel/internal/protocol/SatelModule.java | 11 +- .../internal/api/ShellyApiException.java | 2 +- .../internal/coap/ShellyCoIoTProtocol.java | 2 +- .../discovery/ShellyThingCreator.java | 13 +- .../internal/util/ShellyChannelCache.java | 5 +- .../binding/siemensrds/points/BasePoint.java | 2 +- .../siemensrds/points/StringPoint.java | 10 +- .../internal/conformity/Conformity.java | 4 +- .../converter/SmartthingsHue100Converter.java | 2 +- .../AbstractSnmpTargetHandlerTest.java | 2 +- .../connector/CommunicationStatus.java | 7 +- .../sonos/internal/SonosXMLParser.java | 22 +- .../internal/handler/ZonePlayerHandler.java | 6 +- .../internal/SonyProjectorException.java | 3 +- .../internal/api/SpotifyConnector.java | 7 +- .../handler/SpotifyBridgeHandler.java | 2 +- .../handler/SqueezeBoxPlayerHandler.java | 5 +- .../internal/TACmiChannelTypeProvider.java | 2 +- .../tacmi/internal/schema/ApiPageParser.java | 6 +- .../internal/schema/ChangerX2Parser.java | 12 +- .../telegram/internal/TelegramHandler.java | 2 +- .../internal/action/TelegramActions.java | 12 +- .../internal/handler/TibberHandler.java | 5 +- .../internal/TouchWandBaseUnitHandler.java | 7 +- .../upnpcontrol/internal/UpnpXMLParser.java | 2 +- .../internal/handler/UpnpHandler.java | 4 +- .../internal/handler/UpnpRendererHandler.java | 2 +- .../internal/handler/UpnpServerHandler.java | 16 +- .../velux/internal/VeluxRSBindingConfig.java | 2 +- .../things/VeluxExistingProducts.java | 13 +- .../internal/things/VeluxExistingScenes.java | 2 +- .../velux/internal/things/VeluxGwState.java | 6 +- .../velux/internal/things/VeluxKLFAPI.java | 6 +- .../handler/VenstarThermostatHandler.java | 6 +- .../handler/VerisureEventLogThingHandler.java | 7 +- .../handler/VerisureGatewayThingHandler.java | 5 +- .../volvooncall/internal/dto/TripDetail.java | 11 +- .../internal/handler/VehicleHandler.java | 8 +- .../internal/handler/YamahaBridgeHandler.java | 3 +- .../handler/YamahaZoneThingHandler.java | 3 +- .../internal/lib/services/DeviceManager.java | 26 +- .../internal/handler/ZWayDeviceHandler.java | 16 +- .../internal/HomekitChangeListener.java | 12 +- .../accessories/HomekitAccessoryFactory.java | 4 +- .../hueemulation/internal/NetworkUtils.java | 6 +- .../io/hueemulation/internal/rest/Scenes.java | 3 +- .../rest/mocks/DummyItemRegistry.java | 17 +- .../internal/OpenHabToDeviceConverter.java | 6 +- .../io/neeo/internal/net/HttpRequest.java | 6 +- .../io/neeo/internal/net/HttpResponse.java | 2 +- .../exception/ModbusConnectionException.java | 3 +- ...expectedResponseFunctionCodeException.java | 3 +- ...ModbusUnexpectedResponseSizeException.java | 3 +- ...odbusUnexpectedTransactionIdException.java | 3 +- ...ModbusSlaveErrorResponseExceptionImpl.java | 3 +- .../internal/ModbusSlaveIOExceptionImpl.java | 3 +- .../internal/DynamoDBPersistenceService.java | 2 +- .../AbstractTwoItemIntegrationTest.java | 7 +- .../internal/BaseIntegrationTest.java | 11 +- .../internal/JavaScriptEngineManager.java | 5 +- .../MapTransformationServiceTest.java | 10 +- bundles/pom.xml | 32 ++- .../modbus/tests/AbstractModbusOSGiTest.java | 2 +- itests/pom.xml | 27 ++ pom.xml | 4 + 162 files changed, 933 insertions(+), 575 deletions(-) diff --git a/bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/json/AirQualityJsonCity.java b/bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/json/AirQualityJsonCity.java index 6fc021eb0..b601eadae 100644 --- a/bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/json/AirQualityJsonCity.java +++ b/bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/json/AirQualityJsonCity.java @@ -14,6 +14,7 @@ package org.openhab.binding.airquality.internal.json; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -40,8 +41,6 @@ public class AirQualityJsonCity { } public String getGeo() { - List list = new ArrayList<>(); - geo.forEach(item -> list.add(item.toString())); - return String.join(",", list); + return geo.stream().map(Object::toString).collect(Collectors.joining(", ")); } } diff --git a/bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/json/AirQualityJsonData.java b/bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/json/AirQualityJsonData.java index d1acd66e1..76ec79d67 100644 --- a/bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/json/AirQualityJsonData.java +++ b/bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/json/AirQualityJsonData.java @@ -16,6 +16,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -82,9 +83,8 @@ public class AirQualityJsonData { * @return {String} */ public String getAttributions() { - List list = new ArrayList<>(); - attributions.forEach(item -> list.add(item.getName())); - return "Attributions : " + String.join(", ", list); + String attributionsString = attributions.stream().map(Attribute::getName).collect(Collectors.joining(", ")); + return "Attributions : " + attributionsString; } public String getDominentPol() { diff --git a/bundles/org.openhab.binding.alarmdecoder/src/main/java/org/openhab/binding/alarmdecoder/internal/handler/ADBridgeHandler.java b/bundles/org.openhab.binding.alarmdecoder/src/main/java/org/openhab/binding/alarmdecoder/internal/handler/ADBridgeHandler.java index dada47677..e3eddab79 100644 --- a/bundles/org.openhab.binding.alarmdecoder/src/main/java/org/openhab/binding/alarmdecoder/internal/handler/ADBridgeHandler.java +++ b/bundles/org.openhab.binding.alarmdecoder/src/main/java/org/openhab/binding/alarmdecoder/internal/handler/ADBridgeHandler.java @@ -368,7 +368,7 @@ public abstract class ADBridgeHandler extends BaseBridgeHandler { private static class MessageParseException extends Exception { private static final long serialVersionUID = 1L; - public MessageParseException(String msg) { + public MessageParseException(@Nullable String msg) { super(msg); } } diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/AccountServlet.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/AccountServlet.java index f92e34d48..83c5e1e0e 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/AccountServlet.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/AccountServlet.java @@ -697,9 +697,10 @@ public class AccountServlet extends HttpServlet { } } - void returnError(HttpServletResponse resp, String errorMessage) { + void returnError(HttpServletResponse resp, @Nullable String errorMessage) { try { - resp.getWriter().write("" + StringEscapeUtils.escapeHtml(errorMessage) + "
Try again"); } catch (IOException e) { logger.info("Returning error message failed", e); diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/discovery/SmartHomeDevicesDiscovery.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/discovery/SmartHomeDevicesDiscovery.java index 9316a46c5..c3b322710 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/discovery/SmartHomeDevicesDiscovery.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/discovery/SmartHomeDevicesDiscovery.java @@ -32,6 +32,7 @@ import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.amazonechocontrol.internal.Connection; import org.openhab.binding.amazonechocontrol.internal.handler.AccountHandler; import org.openhab.binding.amazonechocontrol.internal.handler.SmartHomeDeviceHandler; +import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeCapabilities; import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeDevices.DriverIdentity; import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeDevices.SmartHomeDevice; import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeGroups.SmartHomeGroup; @@ -171,7 +172,8 @@ public class SmartHomeDevicesDiscovery extends AbstractDiscoveryService { continue; } - if (Stream.of(shd.capabilities).noneMatch(capability -> capability != null + JsonSmartHomeCapabilities.SmartHomeCapability[] capabilities = shd.capabilities; + if (capabilities == null || Stream.of(capabilities).noneMatch(capability -> capability != null && Constants.SUPPORTED_INTERFACES.contains(capability.interfaceName))) { // No supported interface found continue; diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/SmartHomeDeviceHandler.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/SmartHomeDeviceHandler.java index c9b7900ab..b6a7001ce 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/SmartHomeDeviceHandler.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/SmartHomeDeviceHandler.java @@ -109,7 +109,8 @@ public class SmartHomeDeviceHandler extends BaseThingHandler { } } if (handler != null) { - Collection required = handler.initialize(this, capabilities.get(interfaceName)); + Collection required = handler.initialize(this, + capabilities.getOrDefault(interfaceName, Collections.emptyList())); for (ChannelInfo channelInfo : required) { unusedChannels.remove(channelInfo.channelId); if (addChannelToDevice(thingBuilder, channelInfo.channelId, channelInfo.itemType, diff --git a/bundles/org.openhab.binding.ambientweather/src/main/java/org/openhab/binding/ambientweather/internal/handler/AmbientWeatherBridgeHandler.java b/bundles/org.openhab.binding.ambientweather/src/main/java/org/openhab/binding/ambientweather/internal/handler/AmbientWeatherBridgeHandler.java index d373a9c2e..ed7e10bd2 100644 --- a/bundles/org.openhab.binding.ambientweather/src/main/java/org/openhab/binding/ambientweather/internal/handler/AmbientWeatherBridgeHandler.java +++ b/bundles/org.openhab.binding.ambientweather/src/main/java/org/openhab/binding/ambientweather/internal/handler/AmbientWeatherBridgeHandler.java @@ -62,12 +62,10 @@ public class AmbientWeatherBridgeHandler extends BaseBridgeHandler { private ScheduledFuture validateKeysJob; // Application key is granted only by request from developer - @Nullable - private String applicationKey; + private String applicationKey = ""; // API key assigned to user in ambientweather.net dashboard - @Nullable - private String apiKey; + private String apiKey = ""; // Used Ambient Weather real-time API to retrieve weather data // for weather stations assigned to an API key @@ -151,8 +149,9 @@ public class AmbientWeatherBridgeHandler extends BaseBridgeHandler { return true; } - public void setThingOfflineWithCommError(String errorDetail, String statusDescription) { - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR, statusDescription); + public void setThingOfflineWithCommError(@Nullable String errorDetail, @Nullable String statusDescription) { + String status = statusDescription != null ? statusDescription : "null"; + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR, status); } @Override @@ -213,11 +212,11 @@ public class AmbientWeatherBridgeHandler extends BaseBridgeHandler { updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE); } - public @Nullable String getApplicationKey() { + public String getApplicationKey() { return applicationKey; } - public @Nullable String getApiKey() { + public String getApiKey() { return apiKey; } diff --git a/bundles/org.openhab.binding.ambientweather/src/main/java/org/openhab/binding/ambientweather/internal/processor/RemoteSensor.java b/bundles/org.openhab.binding.ambientweather/src/main/java/org/openhab/binding/ambientweather/internal/processor/RemoteSensor.java index 22f68a7a0..f2e2dccd3 100644 --- a/bundles/org.openhab.binding.ambientweather/src/main/java/org/openhab/binding/ambientweather/internal/processor/RemoteSensor.java +++ b/bundles/org.openhab.binding.ambientweather/src/main/java/org/openhab/binding/ambientweather/internal/processor/RemoteSensor.java @@ -132,6 +132,6 @@ public class RemoteSensor { */ private String convertSoilMoistureToString(double soilMoisture) { Double key = soilMoistureMap.ceilingKey(soilMoisture); - return key == null ? "UNKNOWN" : soilMoistureMap.get(key); + return key == null ? "UNKNOWN" : soilMoistureMap.getOrDefault(key, "UNKNOWN"); } } diff --git a/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/rest/exceptions/AutomowerCommunicationException.java b/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/rest/exceptions/AutomowerCommunicationException.java index 4b0cef23f..2094fbb10 100644 --- a/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/rest/exceptions/AutomowerCommunicationException.java +++ b/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/rest/exceptions/AutomowerCommunicationException.java @@ -15,6 +15,7 @@ package org.openhab.binding.automower.internal.rest.exceptions; import java.io.IOException; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * An exception that occurred while communicating with an automower or an automower bridge @@ -57,8 +58,9 @@ public class AutomowerCommunicationException extends IOException { } @Override - public String getMessage() { - return "Rest call failed: statusCode=" + statusCode + ", message=" + super.getMessage(); + public @Nullable String getMessage() { + String message = super.getMessage(); + return message == null ? null : "Rest call failed: statusCode=" + statusCode + ", message=" + message; } @Override diff --git a/bundles/org.openhab.binding.bluetooth.bluegiga/src/main/java/org/openhab/binding/bluetooth/bluegiga/internal/eir/EirDataType.java b/bundles/org.openhab.binding.bluetooth.bluegiga/src/main/java/org/openhab/binding/bluetooth/bluegiga/internal/eir/EirDataType.java index 82a62b94c..d5b9b955e 100644 --- a/bundles/org.openhab.binding.bluetooth.bluegiga/src/main/java/org/openhab/binding/bluetooth/bluegiga/internal/eir/EirDataType.java +++ b/bundles/org.openhab.binding.bluetooth.bluegiga/src/main/java/org/openhab/binding/bluetooth/bluegiga/internal/eir/EirDataType.java @@ -100,11 +100,7 @@ public enum EirDataType { initMapping(); } - if (codeMapping.get(eirDataType) == null) { - return UNKNOWN; - } - - return codeMapping.get(eirDataType); + return codeMapping.getOrDefault(eirDataType, UNKNOWN); } /** diff --git a/bundles/org.openhab.binding.bluetooth.bluegiga/src/main/java/org/openhab/binding/bluetooth/bluegiga/internal/eir/EirFlags.java b/bundles/org.openhab.binding.bluetooth.bluegiga/src/main/java/org/openhab/binding/bluetooth/bluegiga/internal/eir/EirFlags.java index ff5b4343d..2c152f0e6 100644 --- a/bundles/org.openhab.binding.bluetooth.bluegiga/src/main/java/org/openhab/binding/bluetooth/bluegiga/internal/eir/EirFlags.java +++ b/bundles/org.openhab.binding.bluetooth.bluegiga/src/main/java/org/openhab/binding/bluetooth/bluegiga/internal/eir/EirFlags.java @@ -75,11 +75,7 @@ public enum EirFlags { initMapping(); } - if (codeMapping.get(eirFlag) == null) { - return UNKNOWN; - } - - return codeMapping.get(eirFlag); + return codeMapping.getOrDefault(eirFlag, UNKNOWN); } /** diff --git a/bundles/org.openhab.binding.bluetooth.roaming/src/main/java/org/openhab/binding/bluetooth/roaming/internal/RoamingBluetoothDevice.java b/bundles/org.openhab.binding.bluetooth.roaming/src/main/java/org/openhab/binding/bluetooth/roaming/internal/RoamingBluetoothDevice.java index 0c73a7b65..e992d4a43 100644 --- a/bundles/org.openhab.binding.bluetooth.roaming/src/main/java/org/openhab/binding/bluetooth/roaming/internal/RoamingBluetoothDevice.java +++ b/bundles/org.openhab.binding.bluetooth.roaming/src/main/java/org/openhab/binding/bluetooth/roaming/internal/RoamingBluetoothDevice.java @@ -56,7 +56,10 @@ public class RoamingBluetoothDevice extends DelegateBluetoothDevice { } public void removeBluetoothDevice(BluetoothDevice device) { - device.removeListener(devices.remove(device)); + BluetoothDeviceListener listener = devices.remove(device); + if (listener != null) { + device.removeListener(listener); + } } @Override diff --git a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/SmartherApiConnector.java b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/SmartherApiConnector.java index 11aa8d604..34e6c0215 100644 --- a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/SmartherApiConnector.java +++ b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/SmartherApiConnector.java @@ -197,7 +197,8 @@ public class SmartherApiConnector { } } } catch (ExecutionException e) { - future.completeExceptionally(e.getCause()); + Throwable cause = e.getCause(); + future.completeExceptionally(cause != null ? cause : e); } catch (SmartherGatewayException e) { future.completeExceptionally(e); } catch (RuntimeException | TimeoutException e) { diff --git a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/dto/Enums.java b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/dto/Enums.java index 05646a03c..0485966b4 100644 --- a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/dto/Enums.java +++ b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/dto/Enums.java @@ -243,9 +243,12 @@ public class Enums { public static & TypeWithIntProperty> E lookup(Class en, int value) throws SmartherIllegalPropertyValueException { - for (E constant : en.getEnumConstants()) { - if (constant.getValue() == value) { - return constant; + E[] constants = en.getEnumConstants(); + if (constants != null) { + for (E constant : constants) { + if (constant.getValue() == value) { + return constant; + } } } throw new SmartherIllegalPropertyValueException(en.getSimpleName(), String.valueOf(value)); @@ -257,9 +260,12 @@ public class Enums { public static & TypeWithStringProperty> E lookup(Class en, String value) throws SmartherIllegalPropertyValueException { - for (E constant : en.getEnumConstants()) { - if (constant.getValue().equals(value)) { - return constant; + E[] constants = en.getEnumConstants(); + if (constants != null) { + for (E constant : constants) { + if (constant.getValue().equals(value)) { + return constant; + } } } throw new SmartherIllegalPropertyValueException(en.getSimpleName(), value); diff --git a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/exception/SmartherAuthorizationException.java b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/exception/SmartherAuthorizationException.java index f24e0f4ef..69c087473 100644 --- a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/exception/SmartherAuthorizationException.java +++ b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/exception/SmartherAuthorizationException.java @@ -13,6 +13,7 @@ package org.openhab.binding.bticinosmarther.internal.api.exception; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * Signals that a generic OAuth2 authorization issue with API gateway has occurred. @@ -30,7 +31,7 @@ public class SmartherAuthorizationException extends SmartherGatewayException { * @param message * the error message returned from the API gateway */ - public SmartherAuthorizationException(String message) { + public SmartherAuthorizationException(@Nullable String message) { super(message); } @@ -42,7 +43,7 @@ public class SmartherAuthorizationException extends SmartherGatewayException { * @param cause * the cause (a null value is permitted, and indicates that the cause is nonexistent or unknown) */ - public SmartherAuthorizationException(String message, Throwable cause) { + public SmartherAuthorizationException(@Nullable String message, @Nullable Throwable cause) { super(message, cause); } } diff --git a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/exception/SmartherGatewayException.java b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/exception/SmartherGatewayException.java index ca7233f3c..f235116e5 100644 --- a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/exception/SmartherGatewayException.java +++ b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/exception/SmartherGatewayException.java @@ -15,6 +15,7 @@ package org.openhab.binding.bticinosmarther.internal.api.exception; import java.io.IOException; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * Signals that a generic communication issue with API gateway has occurred. @@ -32,7 +33,7 @@ public class SmartherGatewayException extends IOException { * @param message * the error message returned from the API gateway */ - public SmartherGatewayException(String message) { + public SmartherGatewayException(@Nullable String message) { super(message); } @@ -44,7 +45,7 @@ public class SmartherGatewayException extends IOException { * @param cause * the cause (a null value is permitted, and indicates that the cause is nonexistent or unknown) */ - public SmartherGatewayException(String message, Throwable cause) { + public SmartherGatewayException(@Nullable String message, @Nullable Throwable cause) { super(message, cause); } @@ -57,7 +58,7 @@ public class SmartherGatewayException extends IOException { * @param cause * the cause (a null value is permitted, and indicates that the cause is nonexistent or unknown) */ - public SmartherGatewayException(Throwable cause) { + public SmartherGatewayException(@Nullable Throwable cause) { super(cause); } } diff --git a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/exception/SmartherInvalidResponseException.java b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/exception/SmartherInvalidResponseException.java index 857a78de6..5ee0f25c6 100644 --- a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/exception/SmartherInvalidResponseException.java +++ b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/exception/SmartherInvalidResponseException.java @@ -13,6 +13,7 @@ package org.openhab.binding.bticinosmarther.internal.api.exception; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * Signals that an "invalid response" messaging issue with API gateway has occurred. @@ -30,7 +31,7 @@ public class SmartherInvalidResponseException extends SmartherGatewayException { * @param message * the error message returned from the API gateway */ - public SmartherInvalidResponseException(String message) { + public SmartherInvalidResponseException(@Nullable String message) { super(message); } } diff --git a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/util/DateUtil.java b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/util/DateUtil.java index 4993edc69..a1f5cb29c 100644 --- a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/util/DateUtil.java +++ b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/util/DateUtil.java @@ -17,6 +17,7 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -45,6 +46,9 @@ public final class DateUtil { * if the string cannot be parsed to a local date */ public static LocalDate parseDate(@Nullable String str, String pattern) { + if (str == null) { + throw new DateTimeParseException("date string is null", "", 0); + } DateTimeFormatter dtf = DateTimeFormatter.ofPattern(pattern); return LocalDate.parse(str, dtf); } @@ -63,6 +67,9 @@ public final class DateUtil { * if the string cannot be parsed to a local date and time */ public static LocalDateTime parseLocalTime(@Nullable String str, String pattern) { + if (str == null) { + throw new DateTimeParseException("time string is null", "", 0); + } DateTimeFormatter dtf = DateTimeFormatter.ofPattern(pattern); return LocalDateTime.parse(str, dtf); } @@ -81,6 +88,9 @@ public final class DateUtil { * if the string cannot be parsed to a date and time with timezone */ public static ZonedDateTime parseZonedTime(@Nullable String str, String pattern) { + if (str == null) { + throw new DateTimeParseException("zoned string is null", "", 0); + } DateTimeFormatter dtf = DateTimeFormatter.ofPattern(pattern); return ZonedDateTime.parse(str, dtf); } diff --git a/bundles/org.openhab.binding.buienradar/src/main/java/org/openhab/binding/buienradar/internal/buienradarapi/BuienradarParseException.java b/bundles/org.openhab.binding.buienradar/src/main/java/org/openhab/binding/buienradar/internal/buienradarapi/BuienradarParseException.java index 9a1ca6631..7dbf6026b 100644 --- a/bundles/org.openhab.binding.buienradar/src/main/java/org/openhab/binding/buienradar/internal/buienradarapi/BuienradarParseException.java +++ b/bundles/org.openhab.binding.buienradar/src/main/java/org/openhab/binding/buienradar/internal/buienradarapi/BuienradarParseException.java @@ -13,6 +13,7 @@ package org.openhab.binding.buienradar.internal.buienradarapi; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * An exception thrown when a result from Buienradar could not be correctly parsed. @@ -28,19 +29,19 @@ public class BuienradarParseException extends Exception { super(); } - public BuienradarParseException(String message) { + public BuienradarParseException(@Nullable String message) { super(message); } - public BuienradarParseException(Throwable cause) { + public BuienradarParseException(@Nullable Throwable cause) { super(cause); } - public BuienradarParseException(String message, Throwable cause) { + public BuienradarParseException(@Nullable String message, @Nullable Throwable cause) { super(message, cause); } - public BuienradarParseException(String message, Throwable cause, boolean enableSuppression, + public BuienradarParseException(@Nullable String message, @Nullable Throwable cause, boolean enableSuppression, boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); } diff --git a/bundles/org.openhab.binding.buienradar/src/main/java/org/openhab/binding/buienradar/internal/buienradarapi/BuienradarPredictionAPI.java b/bundles/org.openhab.binding.buienradar/src/main/java/org/openhab/binding/buienradar/internal/buienradarapi/BuienradarPredictionAPI.java index 137a0c957..05aa1ab3b 100644 --- a/bundles/org.openhab.binding.buienradar/src/main/java/org/openhab/binding/buienradar/internal/buienradarapi/BuienradarPredictionAPI.java +++ b/bundles/org.openhab.binding.buienradar/src/main/java/org/openhab/binding/buienradar/internal/buienradarapi/BuienradarPredictionAPI.java @@ -162,7 +162,8 @@ public class BuienradarPredictionAPI implements PredictionAPI { actual = Optional.of(prediction.getActualDateTime()); predictions.add(prediction); } catch (BuienradarParseException e) { - errors.add(e.getMessage()); + String error = e.getMessage(); + errors.add(error != null ? error : "null"); } } if (!errors.isEmpty()) { diff --git a/bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/CaddxMessage.java b/bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/CaddxMessage.java index 86b88123c..a9998d403 100644 --- a/bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/CaddxMessage.java +++ b/bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/CaddxMessage.java @@ -196,7 +196,7 @@ public class CaddxMessage { logger.debug("Message does not contain property [{}]", property); return ""; } - return propertyMap.get(property); + return propertyMap.getOrDefault(property, ""); } public String getPropertyById(String id) { @@ -204,7 +204,7 @@ public class CaddxMessage { logger.debug("Message does not contain id [{}]", id); return ""; } - return idMap.get(id); + return idMap.getOrDefault(id, ""); } public int @Nullable [] getReplyMessageNumbers() { diff --git a/bundles/org.openhab.binding.darksky/src/main/java/org/openhab/binding/darksky/internal/connection/DarkSkyCommunicationException.java b/bundles/org.openhab.binding.darksky/src/main/java/org/openhab/binding/darksky/internal/connection/DarkSkyCommunicationException.java index 206d23a55..fecec898c 100644 --- a/bundles/org.openhab.binding.darksky/src/main/java/org/openhab/binding/darksky/internal/connection/DarkSkyCommunicationException.java +++ b/bundles/org.openhab.binding.darksky/src/main/java/org/openhab/binding/darksky/internal/connection/DarkSkyCommunicationException.java @@ -13,6 +13,7 @@ package org.openhab.binding.darksky.internal.connection; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * The {@link DarkSkyCommunicationException} is a communication exception for the connections to Dark Sky API. @@ -36,7 +37,7 @@ public class DarkSkyCommunicationException extends RuntimeException { * * @param message Detail message */ - public DarkSkyCommunicationException(String message) { + public DarkSkyCommunicationException(@Nullable String message) { super(message); } @@ -45,7 +46,7 @@ public class DarkSkyCommunicationException extends RuntimeException { * * @param cause The cause */ - public DarkSkyCommunicationException(Throwable cause) { + public DarkSkyCommunicationException(@Nullable Throwable cause) { super(cause); } @@ -55,7 +56,7 @@ public class DarkSkyCommunicationException extends RuntimeException { * @param message Detail message * @param cause The cause */ - public DarkSkyCommunicationException(String message, Throwable cause) { + public DarkSkyCommunicationException(@Nullable String message, @Nullable Throwable cause) { super(message, cause); } } diff --git a/bundles/org.openhab.binding.darksky/src/main/java/org/openhab/binding/darksky/internal/connection/DarkSkyConfigurationException.java b/bundles/org.openhab.binding.darksky/src/main/java/org/openhab/binding/darksky/internal/connection/DarkSkyConfigurationException.java index 3ffb84705..a9370ecf7 100644 --- a/bundles/org.openhab.binding.darksky/src/main/java/org/openhab/binding/darksky/internal/connection/DarkSkyConfigurationException.java +++ b/bundles/org.openhab.binding.darksky/src/main/java/org/openhab/binding/darksky/internal/connection/DarkSkyConfigurationException.java @@ -13,6 +13,7 @@ package org.openhab.binding.darksky.internal.connection; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * The {@link DarkSkyConfigurationException} is a configuration exception for the connections to Dark Sky API. @@ -36,7 +37,7 @@ public class DarkSkyConfigurationException extends IllegalArgumentException { * * @param message Detail message */ - public DarkSkyConfigurationException(String message) { + public DarkSkyConfigurationException(@Nullable String message) { super(message); } @@ -45,7 +46,7 @@ public class DarkSkyConfigurationException extends IllegalArgumentException { * * @param cause The cause */ - public DarkSkyConfigurationException(Throwable cause) { + public DarkSkyConfigurationException(@Nullable Throwable cause) { super(cause); } @@ -55,7 +56,7 @@ public class DarkSkyConfigurationException extends IllegalArgumentException { * @param message Detail message * @param cause The cause */ - public DarkSkyConfigurationException(String message, Throwable cause) { + public DarkSkyConfigurationException(@Nullable String message, @Nullable Throwable cause) { super(message, cause); } } diff --git a/bundles/org.openhab.binding.darksky/src/main/java/org/openhab/binding/darksky/internal/connection/DarkSkyConnection.java b/bundles/org.openhab.binding.darksky/src/main/java/org/openhab/binding/darksky/internal/connection/DarkSkyConnection.java index 5adbe8ce3..5beb05eee 100644 --- a/bundles/org.openhab.binding.darksky/src/main/java/org/openhab/binding/darksky/internal/connection/DarkSkyConnection.java +++ b/bundles/org.openhab.binding.darksky/src/main/java/org/openhab/binding/darksky/internal/connection/DarkSkyConnection.java @@ -163,7 +163,7 @@ public class DarkSkyConnection { } private String buildURL(String url, Map requestParams) { - return requestParams.keySet().stream().map(key -> key + "=" + encodeParam(requestParams.get(key))) + return requestParams.entrySet().stream().map(e -> e.getKey() + "=" + encodeParam(e.getValue())) .collect(joining("&", url + "?", "")); } diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java index 24983d838..6b966fb24 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java @@ -105,8 +105,10 @@ public class LightThingHandler extends DeconzBaseThingHandler { || thing.getThingTypeUID().equals(THING_TYPE_EXTENDED_COLOR_LIGHT)) { try { Map properties = thing.getProperties(); - ctMax = Integer.parseInt(properties.get(PROPERTY_CT_MAX)); - ctMin = Integer.parseInt(properties.get(PROPERTY_CT_MIN)); + String ctMaxString = properties.get(PROPERTY_CT_MAX); + ctMax = ctMaxString == null ? ZCL_CT_MAX : Integer.parseInt(ctMaxString); + String ctMinString = properties.get(PROPERTY_CT_MIN); + ctMin = ctMinString == null ? ZCL_CT_MIN : Integer.parseInt(ctMinString); // minimum and maximum are inverted due to mired/kelvin conversion! StateDescription stateDescription = StateDescriptionFragmentBuilder.create() diff --git a/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/manager/impl/DeviceStatusManagerImpl.java b/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/manager/impl/DeviceStatusManagerImpl.java index 6ec5d8010..ccaa75c3d 100644 --- a/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/manager/impl/DeviceStatusManagerImpl.java +++ b/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/manager/impl/DeviceStatusManagerImpl.java @@ -1280,22 +1280,27 @@ public class DeviceStatusManagerImpl implements DeviceStatusManager { @Override public void handleEvent(EventItem eventItem) { - if (EventNames.DEVICE_SENSOR_VALUE.equals(eventItem.getName()) - || EventNames.DEVICE_BINARY_INPUT_EVENT.equals(eventItem.getName())) { - logger.debug("Detect {} eventItem = {}", eventItem.getName(), eventItem.toString()); - Device dev = getDeviceOfEvent(eventItem); - if (dev != null) { - if (EventNames.DEVICE_SENSOR_VALUE.equals(eventItem.getName())) { - dev.setDeviceSensorByEvent(eventItem); - } else { - DeviceBinarayInputEnum binaryInputType = DeviceBinarayInputEnum.getdeviceBinarayInput( - Short.parseShort(eventItem.getProperties().get(EventResponseEnum.INPUT_TYPE))); - Short newState = Short.parseShort(eventItem.getProperties().get(EventResponseEnum.INPUT_STATE)); - if (binaryInputType != null) { - dev.setBinaryInputState(binaryInputType, newState); + try { + if (EventNames.DEVICE_SENSOR_VALUE.equals(eventItem.getName()) + || EventNames.DEVICE_BINARY_INPUT_EVENT.equals(eventItem.getName())) { + logger.debug("Detect {} eventItem = {}", eventItem.getName(), eventItem.toString()); + Device dev = getDeviceOfEvent(eventItem); + if (dev != null) { + if (EventNames.DEVICE_SENSOR_VALUE.equals(eventItem.getName())) { + dev.setDeviceSensorByEvent(eventItem); + } else { + DeviceBinarayInputEnum binaryInputType = DeviceBinarayInputEnum.getdeviceBinarayInput(Short + .parseShort(eventItem.getProperties().getOrDefault(EventResponseEnum.INPUT_TYPE, ""))); + Short newState = Short + .parseShort(eventItem.getProperties().getOrDefault(EventResponseEnum.INPUT_STATE, "")); + if (binaryInputType != null) { + dev.setBinaryInputState(binaryInputType, newState); + } } } } + } catch (NumberFormatException e) { + logger.debug("Unexpected missing or invalid number while handling event", e); } } diff --git a/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/manager/impl/TemperatureControlManager.java b/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/manager/impl/TemperatureControlManager.java index 023f98043..975511489 100644 --- a/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/manager/impl/TemperatureControlManager.java +++ b/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/manager/impl/TemperatureControlManager.java @@ -284,54 +284,64 @@ public class TemperatureControlManager implements EventHandler, TemperatureContr @Override public void handleEvent(EventItem eventItem) { - logger.debug("detect event: {}", eventItem.toString()); - if (eventItem.getName().equals(EventNames.ZONE_SENSOR_VALUE)) { - if (zoneTemperationControlListenerMap != null) { - if (SensorEnum.ROOM_TEMPERATURE_SET_POINT.getSensorType().toString() - .equals(eventItem.getProperties().get(EventResponseEnum.SENSOR_TYPE))) { - Integer zoneID = Integer.parseInt(eventItem.getSource().get(EventResponseEnum.ZONEID)); - if (zoneTemperationControlListenerMap.get(zoneID) != null) { - Float newValue = Float - .parseFloat(eventItem.getProperties().get(EventResponseEnum.SENSOR_VALUE_FLOAT)); - if (!isEcho(zoneID, SensorEnum.ROOM_TEMPERATURE_CONTROL_VARIABLE, newValue)) { - zoneTemperationControlListenerMap.get(zoneID).onTargetTemperatureChanged(newValue); + try { + logger.debug("detect event: {}", eventItem.toString()); + if (eventItem.getName().equals(EventNames.ZONE_SENSOR_VALUE)) { + if (zoneTemperationControlListenerMap != null) { + if (SensorEnum.ROOM_TEMPERATURE_SET_POINT.getSensorType().toString() + .equals(eventItem.getProperties().get(EventResponseEnum.SENSOR_TYPE))) { + Integer zoneID = Integer + .parseInt(eventItem.getSource().getOrDefault(EventResponseEnum.ZONEID, "")); + if (zoneTemperationControlListenerMap.get(zoneID) != null) { + + Float newValue = Float.parseFloat( + eventItem.getProperties().getOrDefault(EventResponseEnum.SENSOR_VALUE_FLOAT, "")); + if (!isEcho(zoneID, SensorEnum.ROOM_TEMPERATURE_CONTROL_VARIABLE, newValue)) { + zoneTemperationControlListenerMap.get(zoneID).onTargetTemperatureChanged(newValue); + } } } - } - if (SensorEnum.ROOM_TEMPERATURE_CONTROL_VARIABLE.getSensorType().toString() - .equals(eventItem.getProperties().get(EventResponseEnum.SENSOR_TYPE))) { - Integer zoneID = Integer.parseInt(eventItem.getSource().get(EventResponseEnum.ZONEID)); - if (zoneTemperationControlListenerMap.get(zoneID) != null) { - Float newValue = Float - .parseFloat(eventItem.getProperties().get(EventResponseEnum.SENSOR_VALUE_FLOAT)); - if (!isEcho(zoneID, SensorEnum.ROOM_TEMPERATURE_CONTROL_VARIABLE, newValue)) { - zoneTemperationControlListenerMap.get(zoneID).onControlValueChanged(newValue.intValue()); + if (SensorEnum.ROOM_TEMPERATURE_CONTROL_VARIABLE.getSensorType().toString() + .equals(eventItem.getProperties().get(EventResponseEnum.SENSOR_TYPE))) { + Integer zoneID = Integer + .parseInt(eventItem.getSource().getOrDefault(EventResponseEnum.ZONEID, "")); + if (zoneTemperationControlListenerMap.get(zoneID) != null) { + Float newValue = Float.parseFloat( + eventItem.getProperties().getOrDefault(EventResponseEnum.SENSOR_VALUE_FLOAT, "")); + if (!isEcho(zoneID, SensorEnum.ROOM_TEMPERATURE_CONTROL_VARIABLE, newValue)) { + zoneTemperationControlListenerMap.get(zoneID) + .onControlValueChanged(newValue.intValue()); + } } } } } - } - if (eventItem.getName().equals(EventNames.HEATING_CONTROL_OPERATION_MODE)) { - if (EVALUATE_REAL_ACTIVE_MODE.equals(eventItem.getProperties().get(EventResponseEnum.ACTIONS))) { - Integer zoneID = Integer.parseInt(eventItem.getProperties().get(EventResponseEnum.ZONEID)); - TemperatureControlStatus temperationControlStatus = dSapi - .getZoneTemperatureControlStatus(connectionMananager.getSessionToken(), zoneID, null); - if (temperationControlStatus != null) { - addTemperatureControlStatus(temperationControlStatus); + if (eventItem.getName().equals(EventNames.HEATING_CONTROL_OPERATION_MODE)) { + if (EVALUATE_REAL_ACTIVE_MODE.equals(eventItem.getProperties().get(EventResponseEnum.ACTIONS))) { + Integer zoneID = Integer + .parseInt(eventItem.getProperties().getOrDefault(EventResponseEnum.ZONEID, "")); + TemperatureControlStatus temperationControlStatus = dSapi + .getZoneTemperatureControlStatus(connectionMananager.getSessionToken(), zoneID, null); + if (temperationControlStatus != null) { + addTemperatureControlStatus(temperationControlStatus); + } } } - } - if (eventItem.getName().equals(EventNames.STATE_CHANGED)) { - if (STATE_NAME_HEATING_WATER_SYSTEM.equals(eventItem.getProperties().get(EventResponseEnum.STATE_NAME))) { - currentHeatingWaterSystemStage = eventItem.getProperties().get(EventResponseEnum.STATE); - logger.debug("heating water system state changed to {}", currentHeatingWaterSystemStage); - if (systemStateChangeListener != null) { - systemStateChangeListener.onSystemStateChanged(STATE_NAME_HEATING_WATER_SYSTEM, - currentHeatingWaterSystemStage); + if (eventItem.getName().equals(EventNames.STATE_CHANGED)) { + if (STATE_NAME_HEATING_WATER_SYSTEM + .equals(eventItem.getProperties().get(EventResponseEnum.STATE_NAME))) { + currentHeatingWaterSystemStage = eventItem.getProperties().get(EventResponseEnum.STATE); + logger.debug("heating water system state changed to {}", currentHeatingWaterSystemStage); + if (systemStateChangeListener != null) { + systemStateChangeListener.onSystemStateChanged(STATE_NAME_HEATING_WATER_SYSTEM, + currentHeatingWaterSystemStage); + } } } + } catch (NumberFormatException e) { + logger.debug("Unexpected missing or invalid number while handling event", e); } } diff --git a/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/structure/devices/deviceparameters/impl/DeviceSensorValue.java b/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/structure/devices/deviceparameters/impl/DeviceSensorValue.java index 26f4fdeb4..c88356801 100644 --- a/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/structure/devices/deviceparameters/impl/DeviceSensorValue.java +++ b/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/structure/devices/deviceparameters/impl/DeviceSensorValue.java @@ -87,20 +87,24 @@ public class DeviceSensorValue { * Creates a new {@link DeviceSensorValue} through the properties of a digitalSTROM * {@link EventNames#DEVICE_SENSOR_VALUE} event. * - * @param eventPropertie must not be null + * @param eventProperties must not be null */ - public DeviceSensorValue(Map eventPropertie) { - if (eventPropertie.get(EventResponseEnum.SENSOR_VALUE_FLOAT) != null) { - floatValue = Float.parseFloat(eventPropertie.get(EventResponseEnum.SENSOR_VALUE_FLOAT)); + public DeviceSensorValue(Map eventProperties) { + String strVal = eventProperties.get(EventResponseEnum.SENSOR_VALUE_FLOAT); + if (strVal != null) { + floatValue = Float.parseFloat(strVal); } - if (eventPropertie.get(EventResponseEnum.SENSOR_TYPE) != null) { - sensorType = SensorEnum.getSensor(Short.parseShort(eventPropertie.get(EventResponseEnum.SENSOR_TYPE))); + strVal = eventProperties.get(EventResponseEnum.SENSOR_TYPE); + if (strVal != null) { + sensorType = SensorEnum.getSensor(Short.parseShort(strVal)); } - if (eventPropertie.get(EventResponseEnum.SENSOR_VALUE) != null) { - dsValue = Integer.parseInt(eventPropertie.get(EventResponseEnum.SENSOR_VALUE)); + strVal = eventProperties.get(EventResponseEnum.SENSOR_VALUE); + if (strVal != null) { + dsValue = Integer.parseInt(strVal); } - if (eventPropertie.get(EventResponseEnum.SENSOR_INDEX) != null) { - sensorIndex = Short.parseShort(eventPropertie.get(EventResponseEnum.SENSOR_INDEX)); + strVal = eventProperties.get(EventResponseEnum.SENSOR_INDEX); + if (strVal != null) { + sensorIndex = Short.parseShort(strVal); } timestamp = Date.from(Instant.ofEpochMilli(System.currentTimeMillis())); valid = true; diff --git a/bundles/org.openhab.binding.draytonwiser/src/main/java/org/openhab/binding/draytonwiser/internal/api/DraytonWiserApiException.java b/bundles/org.openhab.binding.draytonwiser/src/main/java/org/openhab/binding/draytonwiser/internal/api/DraytonWiserApiException.java index 0430fd5e0..6bafa0b80 100644 --- a/bundles/org.openhab.binding.draytonwiser/src/main/java/org/openhab/binding/draytonwiser/internal/api/DraytonWiserApiException.java +++ b/bundles/org.openhab.binding.draytonwiser/src/main/java/org/openhab/binding/draytonwiser/internal/api/DraytonWiserApiException.java @@ -13,6 +13,7 @@ package org.openhab.binding.draytonwiser.internal.api; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * Exception thrown in case of api problems. @@ -24,11 +25,11 @@ public class DraytonWiserApiException extends Exception { private static final long serialVersionUID = 1L; - public DraytonWiserApiException(final String message) { + public DraytonWiserApiException(final @Nullable String message) { super(message); } - public DraytonWiserApiException(final String message, final Throwable cause) { + public DraytonWiserApiException(final @Nullable String message, final @Nullable Throwable cause) { super(message, cause); } } diff --git a/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/device/cosem/CosemObjectFactory.java b/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/device/cosem/CosemObjectFactory.java index adf1bc669..60655d7e9 100644 --- a/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/device/cosem/CosemObjectFactory.java +++ b/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/device/cosem/CosemObjectFactory.java @@ -106,44 +106,49 @@ public class CosemObjectFactory { logger.trace("Received obisIdString {}, obisId: {}, values: {}", obisIdString, obisId, cosemStringValues); - CosemObject cosemObject = null; - - if (obisLookupTableFixed.containsKey(reducedObisId)) { - cosemObject = getCosemObjectInternal(obisLookupTableFixed.get(reducedObisId), obisId, cosemStringValues); + CosemObjectType objectType = obisLookupTableFixed.get(reducedObisId); + if (objectType != null) { logger.trace("Found obisId {} in the fixed lookup table", reducedObisId); - } else if (obisLookupTableMultipleFixed.containsKey(reducedObisId)) { - for (CosemObjectType cosemObjectType : obisLookupTableMultipleFixed.get(reducedObisId)) { - cosemObject = getCosemObjectInternal(cosemObjectType, obisId, cosemStringValues); + return getCosemObjectInternal(objectType, obisId, cosemStringValues); + } + + List objectTypeList = obisLookupTableMultipleFixed.get(reducedObisId); + if (objectTypeList != null) { + for (CosemObjectType cosemObjectType : objectTypeList) { + CosemObject cosemObject = getCosemObjectInternal(cosemObjectType, obisId, cosemStringValues); if (cosemObject != null) { logger.trace("Found obisId {} in the fixed lookup table", reducedObisId); - break; + return cosemObject; } } - } else if (obisLookupTableDynamic.containsKey(reducedObisId)) { + } + + objectType = obisLookupTableDynamic.get(reducedObisId); + if (objectType != null) { logger.trace("Found obisId {} in the dynamic lookup table", reducedObisId); - cosemObject = getCosemObjectInternal(obisLookupTableDynamic.get(reducedObisId), obisId, cosemStringValues); - } else if (obisLookupTableFixed.containsKey(reducedObisIdGroupE)) { - cosemObject = getCosemObjectInternal(obisLookupTableFixed.get(reducedObisIdGroupE), obisId, - cosemStringValues); - } else { - for (CosemObjectType obisMsgType : obisWildcardCosemTypeList) { - if (obisMsgType.obisId.equalsWildCard(reducedObisId)) { - cosemObject = getCosemObjectInternal(obisMsgType, obisId, cosemStringValues); - if (cosemObject != null) { - logger.trace("Searched reducedObisId {} in the wild card type list, result: {}", reducedObisId, - cosemObject); - obisLookupTableDynamic.put(reducedObisId, obisMsgType); - break; - } + return getCosemObjectInternal(objectType, obisId, cosemStringValues); + } + + objectType = obisLookupTableFixed.get(reducedObisIdGroupE); + if (objectType != null) { + return getCosemObjectInternal(objectType, obisId, cosemStringValues); + } + + for (CosemObjectType obisMsgType : obisWildcardCosemTypeList) { + if (obisMsgType.obisId.equalsWildCard(reducedObisId)) { + CosemObject cosemObject = getCosemObjectInternal(obisMsgType, obisId, cosemStringValues); + if (cosemObject != null) { + logger.trace("Searched reducedObisId {} in the wild card type list, result: {}", reducedObisId, + cosemObject); + obisLookupTableDynamic.put(reducedObisId, obisMsgType); + return cosemObject; } } } - if (cosemObject == null) { - logger.debug("Received unknown Cosem Object(OBIS id: {})", obisId); - } + logger.debug("Received unknown Cosem Object(OBIS id: {})", obisId); - return cosemObject; + return null; } /** diff --git a/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/discovery/DSMRMeterDiscoveryService.java b/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/discovery/DSMRMeterDiscoveryService.java index 45197eeaa..18392b114 100644 --- a/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/discovery/DSMRMeterDiscoveryService.java +++ b/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/discovery/DSMRMeterDiscoveryService.java @@ -147,9 +147,9 @@ public class DSMRMeterDiscoveryService extends DSMRDiscoveryService implements P .map(Thing::getHandler) .filter(DSMRMeterHandler.class::isInstance) .map(DSMRMeterHandler.class::cast) - .map(DSMRMeterHandler::getMeterDescriptor) + .map(h -> h == null ? null : h.getMeterDescriptor()) + .map(d -> d == null ? null : d.getMeterType()) .filter(Objects::nonNull) - .map(h -> h.getMeterType()) .collect(Collectors.toSet()); // @formatter:on // Create list of all configured meters that are not in the detected list. If not empty meters might not be diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/connection/EnturCommunicationException.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/connection/EnturCommunicationException.java index 816ba8c21..c2a25e623 100644 --- a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/connection/EnturCommunicationException.java +++ b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/connection/EnturCommunicationException.java @@ -13,6 +13,7 @@ package org.openhab.binding.enturno.internal.connection; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * The {@link EnturCommunicationException} is a communication exception for the connections to Entur API. @@ -24,11 +25,11 @@ public class EnturCommunicationException extends RuntimeException { private static final long serialVersionUID = 1L; - public EnturCommunicationException(String message) { + public EnturCommunicationException(@Nullable String message) { super(message); } - public EnturCommunicationException(String message, Throwable cause) { + public EnturCommunicationException(@Nullable String message, @Nullable Throwable cause) { super(message, cause); } } diff --git a/bundles/org.openhab.binding.exec/src/main/java/org/openhab/binding/exec/internal/handler/ExecHandler.java b/bundles/org.openhab.binding.exec/src/main/java/org/openhab/binding/exec/internal/handler/ExecHandler.java index aea1bd360..57b7b050d 100644 --- a/bundles/org.openhab.binding.exec/src/main/java/org/openhab/binding/exec/internal/handler/ExecHandler.java +++ b/bundles/org.openhab.binding.exec/src/main/java/org/openhab/binding/exec/internal/handler/ExecHandler.java @@ -422,6 +422,7 @@ public class ExecHandler extends BaseThingHandler { } public static String getOperatingSystemName() { - return System.getProperty("os.name"); + String osname = System.getProperty("os.name"); + return osname != null ? osname : "unknown"; } } diff --git a/bundles/org.openhab.binding.fmiweather/src/main/java/org/openhab/binding/fmiweather/internal/client/Client.java b/bundles/org.openhab.binding.fmiweather/src/main/java/org/openhab/binding/fmiweather/internal/client/Client.java index 0da89bf05..72ddbc452 100644 --- a/bundles/org.openhab.binding.fmiweather/src/main/java/org/openhab/binding/fmiweather/internal/client/Client.java +++ b/bundles/org.openhab.binding.fmiweather/src/main/java/org/openhab/binding/fmiweather/internal/client/Client.java @@ -83,7 +83,7 @@ public class Client { } private static final NamespaceContext NAMESPACE_CONTEXT = new NamespaceContext() { @Override - public String getNamespaceURI(@Nullable String prefix) { + public @Nullable String getNamespaceURI(@Nullable String prefix) { return NAMESPACES.get(prefix); } diff --git a/bundles/org.openhab.binding.foobot/src/main/java/org/openhab/binding/foobot/internal/FoobotApiException.java b/bundles/org.openhab.binding.foobot/src/main/java/org/openhab/binding/foobot/internal/FoobotApiException.java index 999d669ad..9f5d815f7 100644 --- a/bundles/org.openhab.binding.foobot/src/main/java/org/openhab/binding/foobot/internal/FoobotApiException.java +++ b/bundles/org.openhab.binding.foobot/src/main/java/org/openhab/binding/foobot/internal/FoobotApiException.java @@ -13,6 +13,7 @@ package org.openhab.binding.foobot.internal; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * Exception thrown when problems occur with obtaining data for the foobot api. @@ -24,7 +25,7 @@ public class FoobotApiException extends Exception { private static final long serialVersionUID = 1L; - public FoobotApiException(final int status, final String message) { + public FoobotApiException(final int status, final @Nullable String message) { super(String.format("%s (code: %s)", message, status)); } } diff --git a/bundles/org.openhab.binding.foobot/src/main/java/org/openhab/binding/foobot/internal/handler/FoobotAccountHandler.java b/bundles/org.openhab.binding.foobot/src/main/java/org/openhab/binding/foobot/internal/handler/FoobotAccountHandler.java index e21b3ec26..26498cc44 100644 --- a/bundles/org.openhab.binding.foobot/src/main/java/org/openhab/binding/foobot/internal/handler/FoobotAccountHandler.java +++ b/bundles/org.openhab.binding.foobot/src/main/java/org/openhab/binding/foobot/internal/handler/FoobotAccountHandler.java @@ -15,10 +15,7 @@ package org.openhab.binding.foobot.internal.handler; import static org.openhab.binding.foobot.internal.FoobotBindingConstants.*; import java.time.Duration; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; +import java.util.*; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; diff --git a/bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/GreeException.java b/bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/GreeException.java index 73e350a08..bccdd4afc 100644 --- a/bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/GreeException.java +++ b/bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/GreeException.java @@ -35,20 +35,20 @@ public class GreeException extends Exception { private static final long serialVersionUID = -2337258558995287405L; private static String EX_NONE = "none"; - public GreeException(Exception exception) { + public GreeException(@Nullable Exception exception) { super(exception); } - public GreeException(String message) { + public GreeException(@Nullable String message) { super(message); } - public GreeException(String message, Exception exception) { + public GreeException(@Nullable String message, @Nullable Exception exception) { super(message, exception); } @Override - public String getMessage() { + public @Nullable String getMessage() { return isEmpty() ? "" : nonNullString(super.getMessage()); } diff --git a/bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/discovery/GreeDeviceFinder.java b/bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/discovery/GreeDeviceFinder.java index f72e12473..582f8ca9a 100644 --- a/bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/discovery/GreeDeviceFinder.java +++ b/bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/discovery/GreeDeviceFinder.java @@ -142,7 +142,7 @@ public class GreeDeviceFinder { deviceTable.put(newDevice.getId(), newDevice); } - public GreeAirDevice getDevice(String id) { + public @Nullable GreeAirDevice getDevice(String id) { return deviceTable.get(id); } diff --git a/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java index 920bfed6d..241b3a070 100644 --- a/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java +++ b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java @@ -200,7 +200,11 @@ public class HDPowerViewShadeHandler extends AbstractHubbedThingHandler { } private int getShadeId() throws NumberFormatException { - return Integer.parseInt(getConfigAs(HDPowerViewShadeConfiguration.class).id); + String str = getConfigAs(HDPowerViewShadeConfiguration.class).id; + if (str == null) { + throw new NumberFormatException("null input string"); + } + return Integer.parseInt(str); } private void stopShade() { diff --git a/bundles/org.openhab.binding.heliosventilation/src/main/java/org/openhab/binding/heliosventilation/internal/HeliosPropertiesFormatException.java b/bundles/org.openhab.binding.heliosventilation/src/main/java/org/openhab/binding/heliosventilation/internal/HeliosPropertiesFormatException.java index 199c11cea..061f05552 100644 --- a/bundles/org.openhab.binding.heliosventilation/src/main/java/org/openhab/binding/heliosventilation/internal/HeliosPropertiesFormatException.java +++ b/bundles/org.openhab.binding.heliosventilation/src/main/java/org/openhab/binding/heliosventilation/internal/HeliosPropertiesFormatException.java @@ -13,6 +13,7 @@ package org.openhab.binding.heliosventilation.internal; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * The {@link HeliosPropertiesFormatException} class defines an exception to describe parsing format errors @@ -41,7 +42,7 @@ public class HeliosPropertiesFormatException extends Exception { } @Override - public String getMessage() { + public @Nullable String getMessage() { return "Cannot parse '" + fullSpec + "' for datapoint '" + channelName + "': " + reason; } } diff --git a/bundles/org.openhab.binding.hpprinter/src/main/java/org/openhab/binding/hpprinter/internal/api/HPServerResult.java b/bundles/org.openhab.binding.hpprinter/src/main/java/org/openhab/binding/hpprinter/internal/api/HPServerResult.java index 19f271399..6f162e719 100644 --- a/bundles/org.openhab.binding.hpprinter/src/main/java/org/openhab/binding/hpprinter/internal/api/HPServerResult.java +++ b/bundles/org.openhab.binding.hpprinter/src/main/java/org/openhab/binding/hpprinter/internal/api/HPServerResult.java @@ -27,10 +27,10 @@ public class HPServerResult { private final @Nullable result data; private final String errorMessage; - public HPServerResult(RequestStatus status, String errorMessage) { + public HPServerResult(RequestStatus status, @Nullable String errorMessage) { this.status = status; this.data = null; - this.errorMessage = errorMessage; + this.errorMessage = errorMessage != null ? errorMessage : ""; } public HPServerResult(result data) { diff --git a/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/HueBridge.java b/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/HueBridge.java index b13231dd9..9f981232d 100644 --- a/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/HueBridge.java +++ b/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/HueBridge.java @@ -221,9 +221,12 @@ public class HueBridge { ArrayList lightList = new ArrayList<>(); for (String id : lightMap.keySet()) { + @Nullable T light = lightMap.get(id); - light.setId(id); - lightList.add(light); + if (light != null) { + light.setId(id); + lightList.add(light); + } } return lightList; diff --git a/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/Scene.java b/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/Scene.java index 7a2b05887..c2a1c29d3 100644 --- a/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/Scene.java +++ b/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/Scene.java @@ -144,7 +144,8 @@ public class Scene { if (getGroupId() == null) { return getLightIds().stream().allMatch(id -> group.getLightIds().contains(id)); } else { - return group.getId().contentEquals(getGroupId()); + String groupId = getGroupId(); + return groupId != null ? group.getId().contentEquals(groupId) : false; } } diff --git a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/manager/DeviceStructureManager.java b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/manager/DeviceStructureManager.java index fd68904a9..9ef73b4b8 100644 --- a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/manager/DeviceStructureManager.java +++ b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/manager/DeviceStructureManager.java @@ -186,7 +186,7 @@ public class DeviceStructureManager { * * @return */ - public Device getBridgeDevice() { + public @Nullable Device getBridgeDevice() { return getDeviceMap().get(bridgeDeviceId); } diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/CommandHandler.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/CommandHandler.java index 272856b07..005ee9df8 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/CommandHandler.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/CommandHandler.java @@ -291,8 +291,8 @@ public abstract class CommandHandler { } private int getRampLevel(InsteonChannelConfiguration conf, int defaultValue) { - Map params = conf.getParameters(); - return params.containsKey("ramplevel") ? Integer.parseInt(params.get("ramplevel")) : defaultValue; + String str = conf.getParameters().get("ramplevel"); + return str != null ? Integer.parseInt(str) : defaultValue; } } @@ -642,8 +642,8 @@ public abstract class CommandHandler { } protected double getRampTime(InsteonChannelConfiguration conf, double defaultValue) { - Map params = conf.getParameters(); - return params.containsKey("ramptime") ? Double.parseDouble(params.get("ramptime")) : defaultValue; + String str = conf.getParameters().get("ramptime"); + return str != null ? Double.parseDouble(str) : defaultValue; } } diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/MessageHandler.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/MessageHandler.java index 630cc7560..c7095e226 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/MessageHandler.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/MessageHandler.java @@ -159,9 +159,8 @@ public abstract class MessageHandler { */ protected double getDoubleParameter(String key, double def) { try { - if (parameters.get(key) != null) { - return Double.parseDouble(parameters.get(key)); - } + String str = parameters.get(key); + return str != null ? Double.parseDouble(str) : def; } catch (NumberFormatException e) { logger.warn("malformed int parameter in message handler: {}", key); } diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/driver/hub/ReadByteBuffer.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/driver/hub/ReadByteBuffer.java index bf59b6e44..ad6adcd31 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/driver/hub/ReadByteBuffer.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/driver/hub/ReadByteBuffer.java @@ -102,7 +102,9 @@ public class ReadByteBuffer { } int b = Math.min(len, remaining()); - System.arraycopy(buf, index, bytes, off, b); + if (bytes != null) { + System.arraycopy(buf, index, bytes, off, b); + } index += b; return b; } diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/message/Msg.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/message/Msg.java index 677672281..fdc731565 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/message/Msg.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/message/Msg.java @@ -280,12 +280,13 @@ public class Msg { * @param len the length to copy from the src byte array */ private void initialize(byte[] newData, int offset, int len) { - data = new byte[len]; + byte[] data = new byte[len]; if (offset >= 0 && offset < newData.length) { System.arraycopy(newData, offset, data, 0, len); } else { logger.warn("intialize(): Offset out of bounds!"); } + this.data = data; } /** @@ -344,7 +345,10 @@ public class Msg { throw new FieldException("data index out of bounds!"); } byte[] section = new byte[numBytes]; - System.arraycopy(data, offset, section, 0, numBytes); + byte[] data = this.data; + if (data != null) { + System.arraycopy(data, offset, section, 0, numBytes); + } return section; } diff --git a/bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/KM200Utils.java b/bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/KM200Utils.java index 87ff54736..06b4dceff 100644 --- a/bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/KM200Utils.java +++ b/bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/KM200Utils.java @@ -18,6 +18,7 @@ import java.util.HashMap; import java.util.Map; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.thing.Channel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,8 +36,8 @@ public class KM200Utils { * Translates a service name to a service path (Replaces # through /) * */ - public static String translatesNameToPath(String name) { - return name.replace("#", "/"); + public static @Nullable String translatesNameToPath(@Nullable String name) { + return name == null ? null : name.replace("#", "/"); } /** diff --git a/bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/handler/KM200GatewayHandler.java b/bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/handler/KM200GatewayHandler.java index caa2b8c99..3f993cda5 100644 --- a/bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/handler/KM200GatewayHandler.java +++ b/bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/handler/KM200GatewayHandler.java @@ -436,10 +436,10 @@ public class KM200GatewayHandler extends BaseBridgeHandler { if (null != tmpSerObjekt) { if (parent == null || parent.equals(tmpSerObjekt.getParent())) { synchronized (sendMap) { - if (sendMap.containsKey(actChannel)) { - state = dataHandler.parseJSONData(sendMap.get(actChannel), - tmpSerObjekt.getServiceType(), tmpService, actChTypes, - KM200Utils.getChannelConfigurationStrings(actChannel)); + JsonObject obj = sendMap.get(actChannel); + if (obj != null) { + state = dataHandler.parseJSONData(obj, tmpSerObjekt.getServiceType(), tmpService, + actChTypes, KM200Utils.getChannelConfigurationStrings(actChannel)); } else { state = dataHandler.getProvidersState(tmpService, actChTypes, KM200Utils.getChannelConfigurationStrings(actChannel)); @@ -548,10 +548,10 @@ public class KM200GatewayHandler extends BaseBridgeHandler { synchronized (sendMap) { KM200ServiceObject serObjekt = remoteDevice.getServiceObject(service); if (null != serObjekt) { - if (sendMap.containsKey(channel)) { - state = dataHandler.parseJSONData(sendMap.get(channel), - serObjekt.getServiceType(), service, chTypes, - KM200Utils.getChannelConfigurationStrings(channel)); + JsonObject obj = sendMap.get(channel); + if (obj != null) { + state = dataHandler.parseJSONData(obj, serObjekt.getServiceType(), service, + chTypes, KM200Utils.getChannelConfigurationStrings(channel)); } else { state = dataHandler.getProvidersState(service, chTypes, KM200Utils.getChannelConfigurationStrings(channel)); diff --git a/bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/handler/KM200ThingHandler.java b/bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/handler/KM200ThingHandler.java index e6c81aac3..98b330aae 100644 --- a/bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/handler/KM200ThingHandler.java +++ b/bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/handler/KM200ThingHandler.java @@ -467,7 +467,10 @@ public class KM200ThingHandler extends BaseThingHandler { continue; } /* Search for new services in sub path */ - addChannels(serObj.serviceTreeMap.get(subKey), thing, subChannels, subKey + "_"); + KM200ServiceObject obj = serObj.serviceTreeMap.get(subKey); + if (obj != null) { + addChannels(obj, thing, subChannels, subKey + "_"); + } break; case DATA_TYPE_ERROR_LIST: if ("nbrErrors".equals(subKey) || "error".equals(subKey)) { diff --git a/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/client/AbstractKNXClient.java b/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/client/AbstractKNXClient.java index 863a9518f..00bce0df7 100644 --- a/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/client/AbstractKNXClient.java +++ b/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/client/AbstractKNXClient.java @@ -213,8 +213,9 @@ public abstract class AbstractKNXClient implements NetworkLinkListener, KNXClien private void disconnect(@Nullable Exception e) { releaseConnection(); if (e != null) { + String message = e.getLocalizedMessage(); statusUpdateCallback.updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, - e.getLocalizedMessage()); + message != null ? message : ""); } else { statusUpdateCallback.updateStatus(ThingStatus.OFFLINE); } diff --git a/bundles/org.openhab.binding.kostalinverter/src/main/java/org/openhab/binding/internal/kostal/inverter/KostalInverterFactory.java b/bundles/org.openhab.binding.kostalinverter/src/main/java/org/openhab/binding/internal/kostal/inverter/KostalInverterFactory.java index 94567023d..49d066f8f 100644 --- a/bundles/org.openhab.binding.kostalinverter/src/main/java/org/openhab/binding/internal/kostal/inverter/KostalInverterFactory.java +++ b/bundles/org.openhab.binding.kostalinverter/src/main/java/org/openhab/binding/internal/kostal/inverter/KostalInverterFactory.java @@ -92,9 +92,10 @@ public class KostalInverterFactory extends BaseThingHandlerFactory { return new WebscrapeHandler(thing); } // third generation - if (SUPPORTED_THIRD_GENERATION_THING_TYPES_UIDS.containsKey(thing.getThingTypeUID())) { - return new ThirdGenerationHandler(thing, httpClient, - SUPPORTED_THIRD_GENERATION_THING_TYPES_UIDS.get(thing.getThingTypeUID())); + ThirdGenerationInverterTypes inverterType = SUPPORTED_THIRD_GENERATION_THING_TYPES_UIDS + .get(thing.getThingTypeUID()); + if (inverterType != null) { + return new ThirdGenerationHandler(thing, httpClient, inverterType); } return null; } diff --git a/bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/connection/ConnectionStateMachine.java b/bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/connection/ConnectionStateMachine.java index 9e83f7ffe..559778faa 100644 --- a/bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/connection/ConnectionStateMachine.java +++ b/bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/connection/ConnectionStateMachine.java @@ -75,7 +75,8 @@ public class ConnectionStateMachine extends AbstractStateMachine l.onError(cause.getMessage())); + String message = cause.getMessage(); + Optional.ofNullable(this.listener).ifPresent(l -> l.onError(message != null ? message : "")); logger.debug("Connection Error.", cause); } diff --git a/bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/handler/LGWebOSTVSocket.java b/bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/handler/LGWebOSTVSocket.java index a619750f6..adb9eb652 100644 --- a/bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/handler/LGWebOSTVSocket.java +++ b/bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/handler/LGWebOSTVSocket.java @@ -243,7 +243,8 @@ public class LGWebOSTVSocket { return; } - Optional.ofNullable(this.listener).ifPresent(l -> l.onError(cause.getMessage())); + String message = cause.getMessage(); + Optional.ofNullable(this.listener).ifPresent(l -> l.onError(message != null ? message : "")); } @OnWebSocketClose diff --git a/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/api/EnedisHttpApi.java b/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/api/EnedisHttpApi.java index ba656ec64..01fd10031 100644 --- a/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/api/EnedisHttpApi.java +++ b/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/api/EnedisHttpApi.java @@ -17,6 +17,7 @@ import java.net.HttpCookie; import java.net.URI; import java.time.LocalDate; import java.time.format.DateTimeFormatter; +import java.util.Objects; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; import java.util.regex.Matcher; @@ -125,8 +126,8 @@ public class EnedisHttpApi { AuthData authData = gson.fromJson(result.getContentAsString(), AuthData.class); if (authData.callbacks.size() < 2 || authData.callbacks.get(0).input.size() == 0 - || authData.callbacks.get(1).input.size() == 0 - || !config.username.contentEquals(authData.callbacks.get(0).input.get(0).valueAsString())) { + || authData.callbacks.get(1).input.size() == 0 || !config.username + .equals(Objects.requireNonNull(authData.callbacks.get(0).input.get(0)).valueAsString())) { throw new LinkyException("Authentication error, the authentication_cookie is probably wrong"); } diff --git a/bundles/org.openhab.binding.logreader/src/main/java/org/openhab/binding/logreader/internal/handler/LogHandler.java b/bundles/org.openhab.binding.logreader/src/main/java/org/openhab/binding/logreader/internal/handler/LogHandler.java index 6b061e894..9ed8377d3 100644 --- a/bundles/org.openhab.binding.logreader/src/main/java/org/openhab/binding/logreader/internal/handler/LogHandler.java +++ b/bundles/org.openhab.binding.logreader/src/main/java/org/openhab/binding/logreader/internal/handler/LogHandler.java @@ -36,7 +36,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * The {@link LogReaderHandler} is responsible for handling commands, which are + * The {@link LogHandler} is responsible for handling commands, which are * sent to one of the channels. * * @author Miika Jukka - Initial contribution @@ -80,10 +80,15 @@ public class LogHandler extends BaseThingHandler implements FileReaderListener { @Override public void initialize() { - configuration = getConfigAs(LogReaderConfiguration.class); + String logDir = System.getProperty("openhab.logdir"); + if (logDir == null) { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, + "Cannot determine system log directory."); + return; + } - configuration.filePath = configuration.filePath.replaceFirst("\\$\\{OPENHAB_LOGDIR\\}", - System.getProperty("openhab.logdir")); + configuration = getConfigAs(LogReaderConfiguration.class); + configuration.filePath = configuration.filePath.replaceFirst("\\$\\{OPENHAB_LOGDIR\\}", logDir); logger.debug("Using configuration: {}", configuration); diff --git a/bundles/org.openhab.binding.loxone/src/main/java/org/openhab/binding/loxone/internal/LxServerHandler.java b/bundles/org.openhab.binding.loxone/src/main/java/org/openhab/binding/loxone/internal/LxServerHandler.java index 0ff1b3d48..4a0ea241f 100644 --- a/bundles/org.openhab.binding.loxone/src/main/java/org/openhab/binding/loxone/internal/LxServerHandler.java +++ b/bundles/org.openhab.binding.loxone/src/main/java/org/openhab/binding/loxone/internal/LxServerHandler.java @@ -531,8 +531,17 @@ public class LxServerHandler extends BaseThingHandler implements LxServerHandler channels.addAll(getThing().getChannels()); } channels.sort((c1, c2) -> { - String label = c1.getLabel(); - return label == null ? 1 : label.compareTo(c2.getLabel()); + String label1 = c1.getLabel(); + String label2 = c2.getLabel(); + if (label1 == null && label2 != null) { + return 1; + } else if (label1 != null && label2 == null) { + return -1; + } else if (label1 == null && label2 == null) { + return 0; + } else { + return label1.compareTo(label2); + } }); ThingBuilder builder = editThing(); builder.withChannels(channels); diff --git a/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/xml/DbXmlInfoReader.java b/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/xml/DbXmlInfoReader.java index 5de503156..9e39694b4 100644 --- a/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/xml/DbXmlInfoReader.java +++ b/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/xml/DbXmlInfoReader.java @@ -50,7 +50,11 @@ public class DbXmlInfoReader { xstream = new XStream(driver); configureSecurity(xstream); - setClassLoader(Project.class.getClassLoader()); + ClassLoader classLoader = Project.class.getClassLoader(); + if (classLoader == null) { + throw new UnknownError("Cannot find classloader"); + } + setClassLoader(classLoader); registerAliases(xstream); } diff --git a/bundles/org.openhab.binding.meteoalerte/src/main/java/org/openhab/binding/meteoalerte/internal/handler/MeteoAlerteHandler.java b/bundles/org.openhab.binding.meteoalerte/src/main/java/org/openhab/binding/meteoalerte/internal/handler/MeteoAlerteHandler.java index d77438a38..e29a41fb5 100644 --- a/bundles/org.openhab.binding.meteoalerte/src/main/java/org/openhab/binding/meteoalerte/internal/handler/MeteoAlerteHandler.java +++ b/bundles/org.openhab.binding.meteoalerte/src/main/java/org/openhab/binding/meteoalerte/internal/handler/MeteoAlerteHandler.java @@ -63,12 +63,13 @@ public class MeteoAlerteHandler extends BaseThingHandler { + "facet=etat_vent&facet=etat_pluie_inondation&facet=etat_orage&facet=etat_inondation&facet=etat_neige&facet=etat_canicule&" + "facet=etat_grand_froid&facet=etat_avalanches&refine.nom_dept="; private static final int TIMEOUT_MS = 30000; + private static final String UNKNOWN_COLOR = "b3b3b3"; private static final Map ALERT_COLORS = Map.ofEntries( new AbstractMap.SimpleEntry(AlertLevel.GREEN, "00ff00"), new AbstractMap.SimpleEntry(AlertLevel.YELLOW, "ffff00"), new AbstractMap.SimpleEntry(AlertLevel.ORANGE, "ff6600"), new AbstractMap.SimpleEntry(AlertLevel.RED, "ff0000"), - new AbstractMap.SimpleEntry(AlertLevel.UNKNOWN, "b3b3b3")); + new AbstractMap.SimpleEntry(AlertLevel.UNKNOWN, UNKNOWN_COLOR)); private final Logger logger = LoggerFactory.getLogger(MeteoAlerteHandler.class); // Time zone provider representing time zone configured in openHAB configuration @@ -169,7 +170,7 @@ public class MeteoAlerteHandler extends BaseThingHandler { if (isLinked(channelIcon)) { String resource = getResource(String.format("picto/%s.svg", channelId)); if (resource != null) { - resource = resource.replaceAll(ALERT_COLORS.get(AlertLevel.UNKNOWN), ALERT_COLORS.get(value)); + resource = resource.replaceAll(UNKNOWN_COLOR, ALERT_COLORS.getOrDefault(value, UNKNOWN_COLOR)); } updateState(channelIcon, resource != null ? new RawType(resource.getBytes(), "image/svg+xml") : UnDefType.UNDEF); diff --git a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoCryptoException.java b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoCryptoException.java index adf1663c5..54a575746 100644 --- a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoCryptoException.java +++ b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoCryptoException.java @@ -13,6 +13,7 @@ package org.openhab.binding.miio.internal; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * Will be thrown instead of the many possible errors in the crypto module @@ -31,11 +32,11 @@ public class MiIoCryptoException extends Exception { super(); } - public MiIoCryptoException(String message) { + public MiIoCryptoException(@Nullable String message) { super(message); } - public MiIoCryptoException(String message, Exception e) { + public MiIoCryptoException(@Nullable String message, @Nullable Exception e) { super(message, e); } } diff --git a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/cloud/MiCloudException.java b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/cloud/MiCloudException.java index 8436c1b51..69016b16f 100644 --- a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/cloud/MiCloudException.java +++ b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/cloud/MiCloudException.java @@ -13,6 +13,7 @@ package org.openhab.binding.miio.internal.cloud; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * Will be thrown for cloud errors @@ -30,11 +31,11 @@ public class MiCloudException extends Exception { super(); } - public MiCloudException(String message) { + public MiCloudException(@Nullable String message) { super(message); } - public MiCloudException(String message, Exception e) { + public MiCloudException(@Nullable String message, @Nullable Exception e) { super(message, e); } } diff --git a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoAbstractHandler.java b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoAbstractHandler.java index 0edcd422c..891e43a23 100644 --- a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoAbstractHandler.java +++ b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoAbstractHandler.java @@ -278,8 +278,9 @@ public abstract class MiIoAbstractHandler extends BaseThingHandler implements Mi disconnected("No Response from device"); } - protected void disconnected(String message) { - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR, message); + protected void disconnected(@Nullable String message) { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR, + message != null ? message : ""); final MiIoAsyncCommunication miioCom = this.miioCom; if (miioCom != null) { lastId = miioCom.getId(); diff --git a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/robot/RRMapFileParser.java b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/robot/RRMapFileParser.java index a26cd99d0..095d06bb0 100644 --- a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/robot/RRMapFileParser.java +++ b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/robot/RRMapFileParser.java @@ -28,6 +28,7 @@ import java.util.Map; import java.util.zip.GZIPInputStream; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.miio.internal.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -358,7 +359,11 @@ public class RRMapFileParser { return sw.toString(); } - private void printAreaDetails(ArrayList areas, PrintWriter pw) { + private void printAreaDetails(@Nullable ArrayList areas, PrintWriter pw) { + if (areas == null) { + pw.println("null"); + return; + } areas.forEach(area -> { pw.print("\tArea coordinates:"); for (int i = 0; i < area.length; i++) { @@ -368,7 +373,11 @@ public class RRMapFileParser { }); } - private void printObstacleDetails(ArrayList obstacle, PrintWriter pw) { + private void printObstacleDetails(@Nullable ArrayList obstacle, PrintWriter pw) { + if (obstacle == null) { + pw.println("null"); + return; + } obstacle.forEach(area -> { pw.print("\tObstacle coordinates:"); for (int i = 0; i < area.length; i++) { diff --git a/bundles/org.openhab.binding.milight/src/main/java/org/openhab/binding/milight/internal/protocol/MilightV6SessionManager.java b/bundles/org.openhab.binding.milight/src/main/java/org/openhab/binding/milight/internal/protocol/MilightV6SessionManager.java index 6cbafdeee..a32f87915 100644 --- a/bundles/org.openhab.binding.milight/src/main/java/org/openhab/binding/milight/internal/protocol/MilightV6SessionManager.java +++ b/bundles/org.openhab.binding.milight/src/main/java/org/openhab/binding/milight/internal/protocol/MilightV6SessionManager.java @@ -196,7 +196,7 @@ public class MilightV6SessionManager implements Runnable, Closeable { public CompletableFuture start() { if (willbeclosed) { CompletableFuture f = new CompletableFuture<>(); - f.completeExceptionally(null); + f.completeExceptionally(new IllegalStateException("will be closed")); return f; } if (sessionThread.isAlive()) { diff --git a/bundles/org.openhab.binding.modbus.helioseasycontrols/src/main/java/org/openhab/binding/modbus/helioseasycontrols/internal/HeliosEasyControlsHandler.java b/bundles/org.openhab.binding.modbus.helioseasycontrols/src/main/java/org/openhab/binding/modbus/helioseasycontrols/internal/HeliosEasyControlsHandler.java index d77d146ca..4d0da544e 100644 --- a/bundles/org.openhab.binding.modbus.helioseasycontrols/src/main/java/org/openhab/binding/modbus/helioseasycontrols/internal/HeliosEasyControlsHandler.java +++ b/bundles/org.openhab.binding.modbus.helioseasycontrols/src/main/java/org/openhab/binding/modbus/helioseasycontrols/internal/HeliosEasyControlsHandler.java @@ -339,8 +339,11 @@ public class HeliosEasyControlsHandler extends BaseThingHandler { try { writeValue(channelId, v); if (variableMap != null) { - updateState(variableMap.get(channelId), v); - updateStatus(ThingStatus.ONLINE); + HeliosVariable variable = variableMap.get(channelId); + if (variable != null) { + updateState(variable, v); + updateStatus(ThingStatus.ONLINE); + } } } catch (HeliosException e) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, diff --git a/bundles/org.openhab.binding.modbus.studer/src/main/java/org/openhab/binding/modbus/studer/internal/StuderHandler.java b/bundles/org.openhab.binding.modbus.studer/src/main/java/org/openhab/binding/modbus/studer/internal/StuderHandler.java index a17e0b3d1..3a0d97412 100644 --- a/bundles/org.openhab.binding.modbus.studer/src/main/java/org/openhab/binding/modbus/studer/internal/StuderHandler.java +++ b/bundles/org.openhab.binding.modbus.studer/src/main/java/org/openhab/binding/modbus/studer/internal/StuderHandler.java @@ -18,6 +18,8 @@ import java.util.ArrayList; import java.util.Optional; import java.util.Set; +import javax.measure.Unit; + import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.modbus.handler.ModbusEndpointThingHandler; @@ -38,6 +40,7 @@ import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.binding.BaseThingHandler; import org.openhab.core.thing.binding.ThingHandler; import org.openhab.core.types.Command; +import org.openhab.core.types.State; import org.openhab.core.types.UnDefType; import org.openhab.io.transport.modbus.AsyncModbusFailure; import org.openhab.io.transport.modbus.ModbusCommunicationInterface; @@ -304,8 +307,10 @@ public class StuderHandler extends BaseThingHandler { Float quantity = parser.hexToFloat(hexString); if (quantity != null) { if (type.equals(THING_TYPE_BSP)) { - updateState(CHANNELS_BSP.get(registerNumber), - new QuantityType<>(quantity, UNIT_CHANNELS_BSP.get(registerNumber))); + Unit unit = UNIT_CHANNELS_BSP.get(registerNumber); + if (unit != null) { + internalUpdateState(CHANNELS_BSP.get(registerNumber), new QuantityType<>(quantity, unit)); + } } else if (type.equals(THING_TYPE_XTENDER)) { handlePolledDataXtender(registerNumber, quantity); } else if (type.equals(THING_TYPE_VARIOTRACK)) { @@ -329,18 +334,20 @@ public class StuderHandler extends BaseThingHandler { case CHANNEL_PV2_OPERATING_MODE: VSMode vsmode = StuderParser.getVSModeByCode(quantity.intValue()); if (vsmode == VSMode.UNKNOWN) { - updateState(CHANNELS_VARIOSTRING.get(registerNumber), UnDefType.UNDEF); + internalUpdateState(CHANNELS_VARIOSTRING.get(registerNumber), UnDefType.UNDEF); } else { - updateState(CHANNELS_VARIOSTRING.get(registerNumber), new StringType(vsmode.name())); + internalUpdateState(CHANNELS_VARIOSTRING.get(registerNumber), new StringType(vsmode.name())); } break; case CHANNEL_STATE_VARIOSTRING: OnOffType vsstate = StuderParser.getStateByCode(quantity.intValue()); - updateState(CHANNELS_VARIOSTRING.get(registerNumber), vsstate); + internalUpdateState(CHANNELS_VARIOSTRING.get(registerNumber), vsstate); break; default: - updateState(CHANNELS_VARIOSTRING.get(registerNumber), - new QuantityType<>(quantity, UNIT_CHANNELS_VARIOSTRING.get(registerNumber))); + Unit unit = UNIT_CHANNELS_VARIOSTRING.get(registerNumber); + if (unit != null) { + internalUpdateState(CHANNELS_VARIOSTRING.get(registerNumber), new QuantityType<>(quantity, unit)); + } } } @@ -354,28 +361,30 @@ public class StuderHandler extends BaseThingHandler { case CHANNEL_MODEL_VARIOTRACK: VTType type = StuderParser.getVTTypeByCode(quantity.intValue()); if (type == VTType.UNKNOWN) { - updateState(CHANNELS_VARIOTRACK.get(registerNumber), UnDefType.UNDEF); + internalUpdateState(CHANNELS_VARIOTRACK.get(registerNumber), UnDefType.UNDEF); } else { - updateState(CHANNELS_VARIOTRACK.get(registerNumber), new StringType(type.name())); + internalUpdateState(CHANNELS_VARIOTRACK.get(registerNumber), new StringType(type.name())); } break; case CHANNEL_OPERATING_MODE: VTMode vtmode = StuderParser.getVTModeByCode(quantity.intValue()); if (vtmode == VTMode.UNKNOWN) { - updateState(CHANNELS_VARIOTRACK.get(registerNumber), UnDefType.UNDEF); + internalUpdateState(CHANNELS_VARIOTRACK.get(registerNumber), UnDefType.UNDEF); } else { - updateState(CHANNELS_VARIOTRACK.get(registerNumber), new StringType(vtmode.name())); + internalUpdateState(CHANNELS_VARIOTRACK.get(registerNumber), new StringType(vtmode.name())); } break; case CHANNEL_STATE_VARIOTRACK: OnOffType vtstate = StuderParser.getStateByCode(quantity.intValue()); - updateState(CHANNELS_VARIOTRACK.get(registerNumber), vtstate); + internalUpdateState(CHANNELS_VARIOTRACK.get(registerNumber), vtstate); break; default: - updateState(CHANNELS_VARIOTRACK.get(registerNumber), - new QuantityType<>(quantity, UNIT_CHANNELS_VARIOTRACK.get(registerNumber))); + Unit unit = UNIT_CHANNELS_VARIOTRACK.get(registerNumber); + if (unit != null) { + internalUpdateState(CHANNELS_VARIOTRACK.get(registerNumber), new QuantityType<>(quantity, unit)); + } } } @@ -389,18 +398,20 @@ public class StuderHandler extends BaseThingHandler { case CHANNEL_OPERATING_STATE: ModeXtender mode = StuderParser.getModeXtenderByCode(quantity.intValue()); if (mode == ModeXtender.UNKNOWN) { - updateState(CHANNELS_XTENDER.get(registerNumber), UnDefType.UNDEF); + internalUpdateState(CHANNELS_XTENDER.get(registerNumber), UnDefType.UNDEF); } else { - updateState(CHANNELS_XTENDER.get(registerNumber), new StringType(mode.name())); + internalUpdateState(CHANNELS_XTENDER.get(registerNumber), new StringType(mode.name())); } break; case CHANNEL_STATE_INVERTER: OnOffType xtstate = StuderParser.getStateByCode(quantity.intValue()); - updateState(CHANNELS_XTENDER.get(registerNumber), xtstate); + internalUpdateState(CHANNELS_XTENDER.get(registerNumber), xtstate); break; default: - updateState(CHANNELS_XTENDER.get(registerNumber), - new QuantityType<>(quantity, UNIT_CHANNELS_XTENDER.get(registerNumber))); + Unit unit = UNIT_CHANNELS_XTENDER.get(registerNumber); + if (unit != null) { + internalUpdateState(CHANNELS_XTENDER.get(registerNumber), new QuantityType<>(quantity, unit)); + } } } @@ -439,4 +450,10 @@ public class StuderHandler extends BaseThingHandler { updateStatus(ThingStatus.ONLINE); } } + + protected void internalUpdateState(@Nullable String channelUID, @Nullable State state) { + if (channelUID != null && state != null) { + super.updateState(channelUID, state); + } + } } diff --git a/bundles/org.openhab.binding.modbus.sunspec/src/main/java/org/openhab/binding/modbus/sunspec/internal/discovery/SunspecDiscoveryProcess.java b/bundles/org.openhab.binding.modbus.sunspec/src/main/java/org/openhab/binding/modbus/sunspec/internal/discovery/SunspecDiscoveryProcess.java index 2a486c41d..8627133e3 100644 --- a/bundles/org.openhab.binding.modbus.sunspec/src/main/java/org/openhab/binding/modbus/sunspec/internal/discovery/SunspecDiscoveryProcess.java +++ b/bundles/org.openhab.binding.modbus.sunspec/src/main/java/org/openhab/binding/modbus/sunspec/internal/discovery/SunspecDiscoveryProcess.java @@ -31,6 +31,7 @@ import org.openhab.binding.modbus.sunspec.internal.parser.CommonModelParser; import org.openhab.core.config.discovery.DiscoveryResult; import org.openhab.core.config.discovery.DiscoveryResultBuilder; import org.openhab.core.library.types.DecimalType; +import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.ThingUID; import org.openhab.io.transport.modbus.AsyncModbusFailure; import org.openhab.io.transport.modbus.ModbusBitUtilities; @@ -282,8 +283,12 @@ public class SunspecDiscoveryProcess { return; } - ThingUID thingUID = new ThingUID(SUPPORTED_THING_TYPES_UIDS.get(block.moduleID), handler.getUID(), - Integer.toString(block.address)); + ThingTypeUID thingTypeUID = SUPPORTED_THING_TYPES_UIDS.get(block.moduleID); + if (thingTypeUID == null) { + logger.warn("Found model block but no corresponding thing type UID present: {}", block.moduleID); + return; + } + ThingUID thingUID = new ThingUID(thingTypeUID, handler.getUID(), Integer.toString(block.address)); Map properties = new HashMap<>(); properties.put(PROPERTY_VENDOR, commonBlock.manufacturer); diff --git a/bundles/org.openhab.binding.modbus.sunspec/src/main/java/org/openhab/binding/modbus/sunspec/internal/handler/AbstractSunSpecHandler.java b/bundles/org.openhab.binding.modbus.sunspec/src/main/java/org/openhab/binding/modbus/sunspec/internal/handler/AbstractSunSpecHandler.java index a9401ae3d..2f720ba5a 100644 --- a/bundles/org.openhab.binding.modbus.sunspec/src/main/java/org/openhab/binding/modbus/sunspec/internal/handler/AbstractSunSpecHandler.java +++ b/bundles/org.openhab.binding.modbus.sunspec/src/main/java/org/openhab/binding/modbus/sunspec/internal/handler/AbstractSunSpecHandler.java @@ -171,8 +171,8 @@ public abstract class AbstractSunSpecHandler extends BaseThingHandler { } try { ModelBlock block = new ModelBlock(); - block.address = (int) Double.parseDouble(thing.getProperties().get(PROPERTY_BLOCK_ADDRESS)); - block.length = (int) Double.parseDouble(thing.getProperties().get(PROPERTY_BLOCK_LENGTH)); + block.address = (int) Double.parseDouble(thing.getProperties().getOrDefault(PROPERTY_BLOCK_ADDRESS, "")); + block.length = (int) Double.parseDouble(thing.getProperties().getOrDefault(PROPERTY_BLOCK_LENGTH, "")); return block; } catch (NumberFormatException ex) { logger.debug("Could not parse address and length properties, error: {}", ex.getMessage()); diff --git a/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/handler/MonopriceAudioHandler.java b/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/handler/MonopriceAudioHandler.java index b781ffbdf..c2106041d 100644 --- a/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/handler/MonopriceAudioHandler.java +++ b/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/handler/MonopriceAudioHandler.java @@ -255,7 +255,12 @@ public class MonopriceAudioHandler extends BaseThingHandler implements Monoprice } if (command instanceof RefreshType) { - updateChannelState(zone, channelType, zoneDataMap.get(zone.getZoneId())); + MonopriceAudioZoneDTO zoneDTO = zoneDataMap.get(zone.getZoneId()); + if (zoneDTO != null) { + updateChannelState(zone, channelType, zoneDTO); + } else { + logger.info("Could not execute REFRESH command for zone {}: null", zone.getZoneId()); + } return; } @@ -462,12 +467,12 @@ public class MonopriceAudioHandler extends BaseThingHandler implements Monoprice case MonopriceAudioConnector.KEY_ZONE_UPDATE: String zoneId = updateData.substring(0, 2); - - if (MonopriceAudioZone.VALID_ZONE_IDS.contains(zoneId)) { + MonopriceAudioZoneDTO zoneDTO = zoneDataMap.get(zoneId); + if (MonopriceAudioZone.VALID_ZONE_IDS.contains(zoneId) && zoneDTO != null) { MonopriceAudioZone targetZone = MonopriceAudioZone.fromZoneId(zoneId); - processZoneUpdate(targetZone, zoneDataMap.get(zoneId), updateData); + processZoneUpdate(targetZone, zoneDTO, updateData); } else { - logger.warn("invalid event: {} for key: {}", evt.getValue(), key); + logger.warn("invalid event: {} for key: {} or zone data null", evt.getValue(), key); } break; default: diff --git a/bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/values/NumberValue.java b/bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/values/NumberValue.java index 93edfc1c3..04c6bcacd 100644 --- a/bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/values/NumberValue.java +++ b/bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/values/NumberValue.java @@ -61,10 +61,12 @@ public class NumberValue extends Value { } protected boolean checkConditions(BigDecimal newValue, DecimalType oldvalue) { + BigDecimal min = this.min; if (min != null && newValue.compareTo(min) == -1) { logger.trace("Number not accepted as it is below the configured minimum"); return false; } + BigDecimal max = this.max; if (max != null && newValue.compareTo(max) == 1) { logger.trace("Number not accepted as it is above the configured maximum"); return false; diff --git a/bundles/org.openhab.binding.nanoleaf/src/main/java/org/openhab/binding/nanoleaf/internal/OpenAPIUtils.java b/bundles/org.openhab.binding.nanoleaf/src/main/java/org/openhab/binding/nanoleaf/internal/OpenAPIUtils.java index b101a02c0..a8ace9809 100644 --- a/bundles/org.openhab.binding.nanoleaf/src/main/java/org/openhab/binding/nanoleaf/internal/OpenAPIUtils.java +++ b/bundles/org.openhab.binding.nanoleaf/src/main/java/org/openhab/binding/nanoleaf/internal/OpenAPIUtils.java @@ -145,7 +145,10 @@ public class OpenAPIUtils { } } - public static boolean checkRequiredFirmware(String modelId, String currentFirmwareVersion) { + public static boolean checkRequiredFirmware(@Nullable String modelId, @Nullable String currentFirmwareVersion) { + if (modelId == null || currentFirmwareVersion == null) { + return false; + } int[] currentVer = getFirmwareVersionNumbers(currentFirmwareVersion); int[] requiredVer = getFirmwareVersionNumbers( diff --git a/bundles/org.openhab.binding.nanoleaf/src/main/java/org/openhab/binding/nanoleaf/internal/handler/NanoleafControllerHandler.java b/bundles/org.openhab.binding.nanoleaf/src/main/java/org/openhab/binding/nanoleaf/internal/handler/NanoleafControllerHandler.java index 76d27617c..27742b152 100644 --- a/bundles/org.openhab.binding.nanoleaf/src/main/java/org/openhab/binding/nanoleaf/internal/handler/NanoleafControllerHandler.java +++ b/bundles/org.openhab.binding.nanoleaf/src/main/java/org/openhab/binding/nanoleaf/internal/handler/NanoleafControllerHandler.java @@ -123,16 +123,17 @@ public class NanoleafControllerHandler extends BaseBridgeHandler { setDeviceType(config.deviceType); try { + Map properties = getThing().getProperties(); if (StringUtils.isEmpty(getAddress()) || StringUtils.isEmpty(String.valueOf(getPort()))) { logger.warn("No IP address and port configured for the Nanoleaf controller"); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_PENDING, "@text/error.nanoleaf.controller.noIp"); stopAllJobs(); - } else if (!StringUtils.isEmpty(getThing().getProperties().get(Thing.PROPERTY_FIRMWARE_VERSION)) - && !OpenAPIUtils.checkRequiredFirmware(getThing().getProperties().get(Thing.PROPERTY_MODEL_ID), - getThing().getProperties().get(Thing.PROPERTY_FIRMWARE_VERSION))) { + } else if (!StringUtils.isEmpty(properties.get(Thing.PROPERTY_FIRMWARE_VERSION)) + && !OpenAPIUtils.checkRequiredFirmware(properties.get(Thing.PROPERTY_MODEL_ID), + properties.get(Thing.PROPERTY_FIRMWARE_VERSION))) { logger.warn("Nanoleaf controller firmware is too old: {}. Must be equal or higher than {}", - getThing().getProperties().get(Thing.PROPERTY_FIRMWARE_VERSION), API_MIN_FW_VER_LIGHTPANELS); + properties.get(Thing.PROPERTY_FIRMWARE_VERSION), API_MIN_FW_VER_LIGHTPANELS); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "@text/error.nanoleaf.controller.incompatibleFirmware"); stopAllJobs(); diff --git a/bundles/org.openhab.binding.neeo/src/main/java/org/openhab/binding/neeo/internal/net/HttpResponse.java b/bundles/org.openhab.binding.neeo/src/main/java/org/openhab/binding/neeo/internal/net/HttpResponse.java index 5f1f958d6..909dddaeb 100644 --- a/bundles/org.openhab.binding.neeo/src/main/java/org/openhab/binding/neeo/internal/net/HttpResponse.java +++ b/bundles/org.openhab.binding.neeo/src/main/java/org/openhab/binding/neeo/internal/net/HttpResponse.java @@ -75,9 +75,9 @@ public class HttpResponse { * @param httpCode the http code * @param msg the msg */ - HttpResponse(int httpCode, String msg) { + HttpResponse(int httpCode, @Nullable String msg) { httpStatus = httpCode; - httpReason = msg; + httpReason = msg != null ? msg : ""; contents = null; } diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/AbstractNetatmoThingHandler.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/AbstractNetatmoThingHandler.java index 7a55fba90..53e26aa05 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/AbstractNetatmoThingHandler.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/AbstractNetatmoThingHandler.java @@ -105,12 +105,10 @@ public abstract class AbstractNetatmoThingHandler extends BaseThingHandler { if (bridgeStatus == ThingStatus.ONLINE) { config = getThing().getConfiguration(); - radioHelper = thing.getProperties().containsKey(PROPERTY_SIGNAL_LEVELS) - ? new RadioHelper(thing.getProperties().get(PROPERTY_SIGNAL_LEVELS)) - : null; - batteryHelper = thing.getProperties().containsKey(PROPERTY_BATTERY_LEVELS) - ? new BatteryHelper(thing.getProperties().get(PROPERTY_BATTERY_LEVELS)) - : null; + String signalLevel = thing.getProperties().get(PROPERTY_SIGNAL_LEVELS); + radioHelper = signalLevel != null ? new RadioHelper(signalLevel) : null; + String batteryLevel = thing.getProperties().get(PROPERTY_BATTERY_LEVELS); + batteryHelper = batteryLevel != null ? new BatteryHelper(batteryLevel) : null; updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, "Pending parent object initialization"); initializeThing(); diff --git a/bundles/org.openhab.binding.nibeuplink/src/main/java/org/openhab/binding/nibeuplink/internal/connector/CommunicationStatus.java b/bundles/org.openhab.binding.nibeuplink/src/main/java/org/openhab/binding/nibeuplink/internal/connector/CommunicationStatus.java index 2240b1af0..1ba917e40 100644 --- a/bundles/org.openhab.binding.nibeuplink/src/main/java/org/openhab/binding/nibeuplink/internal/connector/CommunicationStatus.java +++ b/bundles/org.openhab.binding.nibeuplink/src/main/java/org/openhab/binding/nibeuplink/internal/connector/CommunicationStatus.java @@ -47,9 +47,10 @@ public class CommunicationStatus { public final String getMessage() { Exception err = error; + String errMsg = err == null ? err.getMessage() : null; String msg = getHttpCode().getMessage(); - if (err != null && err.getMessage() != null && !err.getMessage().isEmpty()) { - return err.getMessage(); + if (errMsg != null && !errMsg.isEmpty()) { + return errMsg; } else if (msg != null && !msg.isEmpty()) { return msg; } diff --git a/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/protocol/nhc1/NikoHomeControlCommunication1.java b/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/protocol/nhc1/NikoHomeControlCommunication1.java index c84d7ab02..c0b369f18 100644 --- a/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/protocol/nhc1/NikoHomeControlCommunication1.java +++ b/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/protocol/nhc1/NikoHomeControlCommunication1.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledExecutorService; +import java.util.function.Consumer; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -274,39 +275,26 @@ public class NikoHomeControlCommunication1 extends NikoHomeControlCommunication } } + private void setIfPresent(Map data, String key, Consumer consumer) { + String val = data.get(key); + if (val != null) { + consumer.accept(val); + } + } + private synchronized void cmdSystemInfo(Map data) { logger.debug("Niko Home Control: systeminfo"); - if (data.containsKey("swversion")) { - systemInfo.setSwVersion(data.get("swversion")); - } - if (data.containsKey("api")) { - systemInfo.setApi(data.get("api")); - } - if (data.containsKey("time")) { - systemInfo.setTime(data.get("time")); - } - if (data.containsKey("language")) { - systemInfo.setLanguage(data.get("language")); - } - if (data.containsKey("currency")) { - systemInfo.setCurrency(data.get("currency")); - } - if (data.containsKey("units")) { - systemInfo.setUnits(data.get("units")); - } - if (data.containsKey("DST")) { - systemInfo.setDst(data.get("DST")); - } - if (data.containsKey("TZ")) { - systemInfo.setTz(data.get("TZ")); - } - if (data.containsKey("lastenergyerase")) { - systemInfo.setLastEnergyErase(data.get("lastenergyerase")); - } - if (data.containsKey("lastconfig")) { - systemInfo.setLastConfig(data.get("lastconfig")); - } + setIfPresent(data, "swversion", systemInfo::setSwVersion); + setIfPresent(data, "api", systemInfo::setApi); + setIfPresent(data, "time", systemInfo::setTime); + setIfPresent(data, "language", systemInfo::setLanguage); + setIfPresent(data, "currency", systemInfo::setCurrency); + setIfPresent(data, "units", systemInfo::setUnits); + setIfPresent(data, "DST", systemInfo::setDst); + setIfPresent(data, "TZ", systemInfo::setTz); + setIfPresent(data, "lastenergyerase", systemInfo::setLastEnergyErase); + setIfPresent(data, "lastconfig", systemInfo::setLastConfig); } /** @@ -319,12 +307,16 @@ public class NikoHomeControlCommunication1 extends NikoHomeControlCommunication } private void cmdStartEvents(Map data) { - int errorCode = Integer.parseInt(data.get("error")); - - if (errorCode == 0) { - logger.debug("Niko Home Control: start events success"); + String errorCodeString = data.get("error"); + if (errorCodeString != null) { + int errorCode = Integer.parseInt(errorCodeString); + if (errorCode == 0) { + logger.debug("Niko Home Control: start events success"); + } else { + logger.warn("Niko Home Control: error code {} returned on start events", errorCode); + } } else { - logger.warn("Niko Home Control: error code {} returned on start events", errorCode); + logger.warn("Niko Home Control: could not determine error code returned on start events"); } } @@ -347,7 +339,8 @@ public class NikoHomeControlCommunication1 extends NikoHomeControlCommunication for (Map action : data) { String id = action.get("id"); - int state = Integer.parseInt(action.get("value1")); + String value1 = action.get("value1"); + int state = ((value1 == null) || value1.isEmpty() ? 0 : Integer.parseInt(value1)); String value2 = action.get("value2"); int closeTime = ((value2 == null) || value2.isEmpty() ? 0 : Integer.parseInt(value2)); String value3 = action.get("value3"); @@ -396,121 +389,156 @@ public class NikoHomeControlCommunication1 extends NikoHomeControlCommunication } } + private int parseIntOrThrow(@Nullable String str) throws IllegalArgumentException { + if (str == null) + throw new IllegalArgumentException("String is null"); + try { + return Integer.parseInt(str); + } catch (NumberFormatException e) { + throw new IllegalArgumentException(e); + } + } + private void cmdListThermostat(List> data) { logger.debug("Niko Home Control: list thermostats"); for (Map thermostat : data) { - - String id = thermostat.get("id"); - int measured = Integer.parseInt(thermostat.get("measured")); - int setpoint = Integer.parseInt(thermostat.get("setpoint")); - int mode = Integer.parseInt(thermostat.get("mode")); - int overrule = Integer.parseInt(thermostat.get("overrule")); - // overruletime received in "HH:MM" format - String[] overruletimeStrings = thermostat.get("overruletime").split(":"); - int overruletime = 0; - if (overruletimeStrings.length == 2) { - overruletime = Integer.parseInt(overruletimeStrings[0]) * 60 + Integer.parseInt(overruletimeStrings[1]); - } - int ecosave = Integer.parseInt(thermostat.get("ecosave")); - - // For parity with NHC II, assume heating/cooling if thermostat is on and setpoint different from measured - int demand = (mode != 3) ? (setpoint > measured ? 1 : (setpoint < measured ? -1 : 0)) : 0; - - if (!thermostats.containsKey(id)) { - // Initial instantiation of NhcThermostat class for thermostat object - String name = thermostat.get("name"); - String locationId = thermostat.get("location"); - String location = ""; - if (!locationId.isEmpty()) { - location = locations.get(locationId).getName(); + try { + String id = thermostat.get("id"); + int measured = parseIntOrThrow(thermostat.get("measured")); + int setpoint = parseIntOrThrow(thermostat.get("setpoint")); + int mode = parseIntOrThrow(thermostat.get("mode")); + int overrule = parseIntOrThrow(thermostat.get("overrule")); + // overruletime received in "HH:MM" format + String[] overruletimeStrings = thermostat.getOrDefault("overruletime", "").split(":"); + int overruletime = 0; + if (overruletimeStrings.length == 2) { + overruletime = Integer.parseInt(overruletimeStrings[0]) * 60 + + Integer.parseInt(overruletimeStrings[1]); } - NhcThermostat nhcThermostat = new NhcThermostat1(id, name, location, this); - nhcThermostat.updateState(measured, setpoint, mode, overrule, overruletime, ecosave, demand); - thermostats.put(id, nhcThermostat); - } else { - // Thermostat object already exists, so only update state. - // If we would re-instantiate thermostat, we would lose pointer back from thermostat to thing handler - // that was set in thing handler initialize(). - thermostats.get(id).updateState(measured, setpoint, mode, overrule, overruletime, ecosave, demand); + int ecosave = parseIntOrThrow(thermostat.get("ecosave")); + + // For parity with NHC II, assume heating/cooling if thermostat is on and setpoint different from + // measured + int demand = (mode != 3) ? (setpoint > measured ? 1 : (setpoint < measured ? -1 : 0)) : 0; + + NhcThermostat t = thermostats.computeIfAbsent(id, i -> { + // Initial instantiation of NhcThermostat class for thermostat object + String name = thermostat.get("name"); + String locationId = thermostat.get("location"); + String location = ""; + if (!locationId.isEmpty()) { + location = locations.get(locationId).getName(); + } + if (name != null) { + return new NhcThermostat1(i, name, location, this); + } + throw new IllegalArgumentException(); + }); + if (t != null) { + t.updateState(measured, setpoint, mode, overrule, overruletime, ecosave, demand); + } + } catch (IllegalArgumentException e) { + // do nothing } } } private void cmdExecuteActions(Map data) { - int errorCode = Integer.parseInt(data.get("error")); - if (errorCode == 0) { - logger.debug("Niko Home Control: execute action success"); - } else { - logger.warn("Niko Home Control: error code {} returned on command execution", errorCode); + try { + int errorCode = parseIntOrThrow(data.get("error")); + if (errorCode == 0) { + logger.debug("Niko Home Control: execute action success"); + } else { + logger.warn("Niko Home Control: error code {} returned on command execution", errorCode); + } + } catch (IllegalArgumentException e) { + logger.warn("Niko Home Control: no error code returned on command execution"); } } private void cmdExecuteThermostat(Map data) { - int errorCode = Integer.parseInt(data.get("error")); - if (errorCode == 0) { - logger.debug("Niko Home Control: execute thermostats success"); - } else { - logger.warn("Niko Home Control: error code {} returned on command execution", errorCode); + try { + int errorCode = parseIntOrThrow(data.get("error")); + if (errorCode == 0) { + logger.debug("Niko Home Control: execute thermostats success"); + } else { + logger.warn("Niko Home Control: error code {} returned on command execution", errorCode); + } + } catch (IllegalArgumentException e) { + logger.warn("Niko Home Control: no error code returned on command execution"); } } private void eventListActions(List> data) { for (Map action : data) { String id = action.get("id"); - if (!actions.containsKey(id)) { + if (id == null || !actions.containsKey(id)) { logger.warn("Niko Home Control: action in controller not known {}", id); return; } - int state = Integer.parseInt(action.get("value1")); - logger.debug("Niko Home Control: event execute action {} with state {}", id, state); - actions.get(id).setState(state); + String stateString = action.get("value1"); + if (stateString != null) { + int state = Integer.parseInt(stateString); + logger.debug("Niko Home Control: event execute action {} with state {}", id, state); + NhcAction action1 = actions.get(id); + if (action1 != null) { + action1.setState(state); + } + } } } private void eventListThermostat(List> data) { for (Map thermostat : data) { - String id = thermostat.get("id"); - if (!thermostats.containsKey(id)) { - logger.warn("Niko Home Control: thermostat in controller not known {}", id); - return; + try { + String id = thermostat.get("id"); + if (!thermostats.containsKey(id)) { + logger.warn("Niko Home Control: thermostat in controller not known {}", id); + return; + } + + int measured = parseIntOrThrow(thermostat.get("measured")); + int setpoint = parseIntOrThrow(thermostat.get("setpoint")); + int mode = parseIntOrThrow(thermostat.get("mode")); + int overrule = parseIntOrThrow(thermostat.get("overrule")); + // overruletime received in "HH:MM" format + String[] overruletimeStrings = thermostat.getOrDefault("overruletime", "").split(":"); + int overruletime = 0; + if (overruletimeStrings.length == 2) { + overruletime = Integer.parseInt(overruletimeStrings[0]) * 60 + + Integer.parseInt(overruletimeStrings[1]); + } + int ecosave = parseIntOrThrow(thermostat.get("ecosave")); + + int demand = (mode != 3) ? (setpoint > measured ? 1 : (setpoint < measured ? -1 : 0)) : 0; + + logger.debug( + "Niko Home Control: event execute thermostat {} with measured {}, setpoint {}, mode {}, overrule {}, overruletime {}, ecosave {}, demand {}", + id, measured, setpoint, mode, overrule, overruletime, ecosave, demand); + NhcThermostat t = thermostats.get(id); + if (t != null) { + t.updateState(measured, setpoint, mode, overrule, overruletime, ecosave, demand); + } + } catch (IllegalArgumentException e) { + // do nothing } - - int measured = Integer.parseInt(thermostat.get("measured")); - int setpoint = Integer.parseInt(thermostat.get("setpoint")); - int mode = Integer.parseInt(thermostat.get("mode")); - int overrule = Integer.parseInt(thermostat.get("overrule")); - // overruletime received in "HH:MM" format - String[] overruletimeStrings = thermostat.get("overruletime").split(":"); - int overruletime = 0; - if (overruletimeStrings.length == 2) { - overruletime = Integer.parseInt(overruletimeStrings[0]) * 60 + Integer.parseInt(overruletimeStrings[1]); - } - int ecosave = Integer.parseInt(thermostat.get("ecosave")); - - int demand = (mode != 3) ? (setpoint > measured ? 1 : (setpoint < measured ? -1 : 0)) : 0; - - logger.debug( - "Niko Home Control: event execute thermostat {} with measured {}, setpoint {}, mode {}, overrule {}, overruletime {}, ecosave {}, demand {}", - id, measured, setpoint, mode, overrule, overruletime, ecosave, demand); - thermostats.get(id).updateState(measured, setpoint, mode, overrule, overruletime, ecosave, demand); } } private void eventGetAlarms(Map data) { - int type = Integer.parseInt(data.get("type")); String alarmText = data.get("text"); - switch (type) { - case 0: + switch (data.getOrDefault("type", "")) { + case "0": logger.debug("Niko Home Control: alarm - {}", alarmText); handler.alarmEvent(alarmText); break; - case 1: + case "1": logger.debug("Niko Home Control: notice - {}", alarmText); handler.noticeEvent(alarmText); break; default: - logger.debug("Niko Home Control: unexpected message type {}", type); + logger.debug("Niko Home Control: unexpected message type {}", data.get("type")); } } diff --git a/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/protocol/nhc2/NikoHomeControlCommunication2.java b/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/protocol/nhc2/NikoHomeControlCommunication2.java index 8ab2d4269..b3e195b3d 100644 --- a/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/protocol/nhc2/NikoHomeControlCommunication2.java +++ b/bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/protocol/nhc2/NikoHomeControlCommunication2.java @@ -486,9 +486,12 @@ public class NikoHomeControlCommunication2 extends NikoHomeControlCommunication } if (dimmerProperty.isPresent()) { - action.setState(Integer.parseInt(dimmerProperty.get().brightness)); - logger.debug("Niko Home Control: setting action {} internally to {}", action.getId(), - dimmerProperty.get().brightness); + String brightness = dimmerProperty.get().brightness; + if (brightness != null) { + action.setState(Integer.parseInt(brightness)); + logger.debug("Niko Home Control: setting action {} internally to {}", action.getId(), + dimmerProperty.get().brightness); + } } } @@ -507,15 +510,19 @@ public class NikoHomeControlCommunication2 extends NikoHomeControlCommunication Optional overruleActiveProperty = deviceProperties.stream().map(p -> p.overruleActive) .filter(Objects::nonNull).map(t -> Boolean.parseBoolean(t)).findFirst(); Optional overruleSetpointProperty = deviceProperties.stream().map(p -> p.overruleSetpoint) - .filter(s -> !((s == null) || s.isEmpty())).map(t -> Math.round(Float.parseFloat(t) * 10)).findFirst(); + .map(s -> (!((s == null) || s.isEmpty())) ? Math.round(Float.parseFloat(s) * 10) : null) + .filter(Objects::nonNull).findFirst(); Optional overruleTimeProperty = deviceProperties.stream().map(p -> p.overruleTime) - .filter(s -> !((s == null) || s.isEmpty())).map(t -> Math.round(Float.parseFloat(t))).findFirst(); + .map(s -> (!((s == null) || s.isEmpty())) ? Math.round(Float.parseFloat(s)) : null) + .filter(Objects::nonNull).findFirst(); Optional setpointTemperatureProperty = deviceProperties.stream().map(p -> p.setpointTemperature) - .filter(s -> !((s == null) || s.isEmpty())).map(t -> Math.round(Float.parseFloat(t) * 10)).findFirst(); - Optional ecoSaveProperty = deviceProperties.stream().map(p -> p.ecoSave).filter(Objects::nonNull) - .map(t -> Boolean.parseBoolean(t)).findFirst(); + .map(s -> (!((s == null) || s.isEmpty())) ? Math.round(Float.parseFloat(s) * 10) : null) + .filter(Objects::nonNull).findFirst(); + Optional ecoSaveProperty = deviceProperties.stream().map(p -> p.ecoSave) + .map(s -> s != null ? Boolean.parseBoolean(s) : null).filter(Objects::nonNull).findFirst(); Optional ambientTemperatureProperty = deviceProperties.stream().map(p -> p.ambientTemperature) - .filter(s -> !(s == null || s.isEmpty())).map(t -> Math.round(Float.parseFloat(t) * 10)).findFirst(); + .map(s -> (!((s == null) || s.isEmpty())) ? Math.round(Float.parseFloat(s) * 10) : null) + .filter(Objects::nonNull).findFirst(); Optional<@Nullable String> demandProperty = deviceProperties.stream().map(p -> p.demand) .filter(Objects::nonNull).findFirst(); Optional<@Nullable String> operationModeProperty = deviceProperties.stream().map(p -> p.operationMode) diff --git a/bundles/org.openhab.binding.ojelectronics/src/main/java/org/openhab/binding/ojelectronics/internal/ThermostatHandler.java b/bundles/org.openhab.binding.ojelectronics/src/main/java/org/openhab/binding/ojelectronics/internal/ThermostatHandler.java index a914db2e0..7ad55b5c5 100644 --- a/bundles/org.openhab.binding.ojelectronics/src/main/java/org/openhab/binding/ojelectronics/internal/ThermostatHandler.java +++ b/bundles/org.openhab.binding.ojelectronics/src/main/java/org/openhab/binding/ojelectronics/internal/ThermostatHandler.java @@ -158,7 +158,7 @@ public class ThermostatHandler extends BaseThingHandler { updateState(BindingConstants.CHANNEL_OWD5_GROUPNAME, StringType.valueOf(thermostat.groupName)); } - private String getRegulationMode(int regulationMode) { + private @Nullable String getRegulationMode(int regulationMode) { return REGULATION_MODES.get(regulationMode); } diff --git a/bundles/org.openhab.binding.onewire/src/main/java/org/openhab/binding/onewire/internal/SensorId.java b/bundles/org.openhab.binding.onewire/src/main/java/org/openhab/binding/onewire/internal/SensorId.java index ec2e39a03..a2d51b4cc 100644 --- a/bundles/org.openhab.binding.onewire/src/main/java/org/openhab/binding/onewire/internal/SensorId.java +++ b/bundles/org.openhab.binding.onewire/src/main/java/org/openhab/binding/onewire/internal/SensorId.java @@ -43,7 +43,10 @@ public class SensorId { * - characters are case-insensitive * - hubs ("1F.xxxxxxxxxxxx/aux/") may be repeated */ - public SensorId(String fullPath) { + public SensorId(@Nullable String fullPath) { + if (fullPath == null) { + throw new IllegalArgumentException(); + } Matcher matcher = SENSOR_ID_PATTERN.matcher(fullPath); if (matcher.matches() && matcher.groupCount() == 2) { path = matcher.group(1) == null ? "" : matcher.group(1); diff --git a/bundles/org.openhab.binding.onewire/src/main/java/org/openhab/binding/onewire/internal/discovery/OwDiscoveryItem.java b/bundles/org.openhab.binding.onewire/src/main/java/org/openhab/binding/onewire/internal/discovery/OwDiscoveryItem.java index 6ce94388c..30abd9636 100644 --- a/bundles/org.openhab.binding.onewire/src/main/java/org/openhab/binding/onewire/internal/discovery/OwDiscoveryItem.java +++ b/bundles/org.openhab.binding.onewire/src/main/java/org/openhab/binding/onewire/internal/discovery/OwDiscoveryItem.java @@ -118,8 +118,8 @@ public class OwDiscoveryItem { * @return ThingTypeUID if mapping successful */ public ThingTypeUID getThingTypeUID() throws OwException { - if (THING_TYPE_MAP.containsKey(sensorType)) { - thingTypeUID = THING_TYPE_MAP.get(sensorType); + ThingTypeUID thingTypeUID = THING_TYPE_MAP.get(sensorType); + if (thingTypeUID != null) { return thingTypeUID; } else { throw new OwException(sensorType + " cannot be mapped to thing type"); diff --git a/bundles/org.openhab.binding.onewire/src/main/java/org/openhab/binding/onewire/internal/handler/AdvancedMultisensorThingHandler.java b/bundles/org.openhab.binding.onewire/src/main/java/org/openhab/binding/onewire/internal/handler/AdvancedMultisensorThingHandler.java index 7e177740c..a063f28ba 100644 --- a/bundles/org.openhab.binding.onewire/src/main/java/org/openhab/binding/onewire/internal/handler/AdvancedMultisensorThingHandler.java +++ b/bundles/org.openhab.binding.onewire/src/main/java/org/openhab/binding/onewire/internal/handler/AdvancedMultisensorThingHandler.java @@ -90,17 +90,20 @@ public class AdvancedMultisensorThingHandler extends OwBaseThingHandler { return; } - hwRevision = Integer.valueOf(properties.get(PROPERTY_HW_REVISION)); + hwRevision = Integer.valueOf(properties.getOrDefault(PROPERTY_HW_REVISION, "0")); - sensors.add(new DS2438(sensorId, this)); - sensors.add(new DS18x20(new SensorId(properties.get(PROPERTY_DS18B20)), this)); - if (THING_TYPE_AMS.equals(thingType)) { - sensors.add(new DS2438(new SensorId(properties.get(PROPERTY_DS2438)), this)); - sensors.add(new DS2406_DS2413(new SensorId(properties.get(PROPERTY_DS2413)), this)); - digitalRefreshInterval = configuration.digitalRefresh * 1000; - digitalLastRefresh = 0; + try { + sensors.add(new DS2438(sensorId, this)); + sensors.add(new DS18x20(new SensorId(properties.get(PROPERTY_DS18B20)), this)); + if (THING_TYPE_AMS.equals(thingType)) { + sensors.add(new DS2438(new SensorId(properties.get(PROPERTY_DS2438)), this)); + sensors.add(new DS2406_DS2413(new SensorId(properties.get(PROPERTY_DS2413)), this)); + digitalRefreshInterval = configuration.digitalRefresh * 1000; + digitalLastRefresh = 0; + } + } catch (IllegalArgumentException e) { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "properties invalid"); } - scheduler.execute(() -> { configureThingChannels(); }); diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapCommunicationException.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapCommunicationException.java index ca2daef75..4c4101297 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapCommunicationException.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapCommunicationException.java @@ -13,6 +13,7 @@ package org.openhab.binding.openweathermap.internal.connection; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * The {@link OpenWeatherMapCommunicationException} is a communication exception for the connections to OpenWeatherMap @@ -37,7 +38,7 @@ public class OpenWeatherMapCommunicationException extends RuntimeException { * * @param message Detail message */ - public OpenWeatherMapCommunicationException(String message) { + public OpenWeatherMapCommunicationException(@Nullable String message) { super(message); } @@ -46,7 +47,7 @@ public class OpenWeatherMapCommunicationException extends RuntimeException { * * @param cause The cause */ - public OpenWeatherMapCommunicationException(Throwable cause) { + public OpenWeatherMapCommunicationException(@Nullable Throwable cause) { super(cause); } @@ -56,7 +57,7 @@ public class OpenWeatherMapCommunicationException extends RuntimeException { * @param message Detail message * @param cause The cause */ - public OpenWeatherMapCommunicationException(String message, Throwable cause) { + public OpenWeatherMapCommunicationException(@Nullable String message, @Nullable Throwable cause) { super(message, cause); } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConfigurationException.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConfigurationException.java index c5a64388e..71397d23c 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConfigurationException.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConfigurationException.java @@ -13,6 +13,7 @@ package org.openhab.binding.openweathermap.internal.connection; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * The {@link OpenWeatherMapConfigurationException} is a configuration exception for the connections to OpenWeatherMap @@ -37,7 +38,7 @@ public class OpenWeatherMapConfigurationException extends IllegalArgumentExcepti * * @param message Detail message */ - public OpenWeatherMapConfigurationException(String message) { + public OpenWeatherMapConfigurationException(@Nullable String message) { super(message); } @@ -46,7 +47,7 @@ public class OpenWeatherMapConfigurationException extends IllegalArgumentExcepti * * @param cause The cause */ - public OpenWeatherMapConfigurationException(Throwable cause) { + public OpenWeatherMapConfigurationException(@Nullable Throwable cause) { super(cause); } @@ -56,7 +57,7 @@ public class OpenWeatherMapConfigurationException extends IllegalArgumentExcepti * @param message Detail message * @param cause The cause */ - public OpenWeatherMapConfigurationException(String message, Throwable cause) { + public OpenWeatherMapConfigurationException(@Nullable String message, @Nullable Throwable cause) { super(message, cause); } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConnection.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConnection.java index d2705e68a..264ad1c1e 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConnection.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConnection.java @@ -278,7 +278,10 @@ public class OpenWeatherMapConnection { .collect(joining("&", url + "?", "")); } - private String encodeParam(String value) { + private String encodeParam(@Nullable String value) { + if (value == null) { + return ""; + } try { return URLEncoder.encode(value, StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException e) { diff --git a/bundles/org.openhab.binding.pjlinkdevice/src/main/java/org/openhab/binding/pjlinkdevice/internal/device/PJLinkDevice.java b/bundles/org.openhab.binding.pjlinkdevice/src/main/java/org/openhab/binding/pjlinkdevice/internal/device/PJLinkDevice.java index 7a8c945f2..114f9cae9 100644 --- a/bundles/org.openhab.binding.pjlinkdevice/src/main/java/org/openhab/binding/pjlinkdevice/internal/device/PJLinkDevice.java +++ b/bundles/org.openhab.binding.pjlinkdevice/src/main/java/org/openhab/binding/pjlinkdevice/internal/device/PJLinkDevice.java @@ -126,8 +126,9 @@ public class PJLinkDevice { Instant now = Instant.now(); Socket socket = this.socket; boolean connectionTooOld = false; - if (this.socketCreatedOn != null) { - long millisecondsSinceLastConnect = Duration.between(this.socketCreatedOn, now).toMillis(); + Instant socketCreatedOn = this.socketCreatedOn; + if (socketCreatedOn != null) { + long millisecondsSinceLastConnect = Duration.between(socketCreatedOn, now).toMillis(); // according to the PJLink specification, the device closes the connection after 30s idle (without notice), // so to be on the safe side we do not reuse sockets older than 20s connectionTooOld = millisecondsSinceLastConnect > 20 * 1000; diff --git a/bundles/org.openhab.binding.plclogo/src/main/java/org/openhab/binding/plclogo/internal/handler/PLCCommonHandler.java b/bundles/org.openhab.binding.plclogo/src/main/java/org/openhab/binding/plclogo/internal/handler/PLCCommonHandler.java index 56a9ca80d..0996192e9 100644 --- a/bundles/org.openhab.binding.plclogo/src/main/java/org/openhab/binding/plclogo/internal/handler/PLCCommonHandler.java +++ b/bundles/org.openhab.binding.plclogo/src/main/java/org/openhab/binding/plclogo/internal/handler/PLCCommonHandler.java @@ -280,6 +280,10 @@ public abstract class PLCCommonHandler extends BaseThingHandler { } protected static String getBlockFromChannel(final @Nullable Channel channel) { - return channel == null ? NOT_SUPPORTED : channel.getProperties().get(BLOCK_PROPERTY); + if (channel == null) { + return NOT_SUPPORTED; + } + String block = channel.getProperties().get(BLOCK_PROPERTY); + return block == null ? NOT_SUPPORTED : block; } } diff --git a/bundles/org.openhab.binding.plugwise/src/main/java/org/openhab/binding/plugwise/internal/handler/AbstractPlugwiseThingHandler.java b/bundles/org.openhab.binding.plugwise/src/main/java/org/openhab/binding/plugwise/internal/handler/AbstractPlugwiseThingHandler.java index a22582e11..789cc555c 100644 --- a/bundles/org.openhab.binding.plugwise/src/main/java/org/openhab/binding/plugwise/internal/handler/AbstractPlugwiseThingHandler.java +++ b/bundles/org.openhab.binding.plugwise/src/main/java/org/openhab/binding/plugwise/internal/handler/AbstractPlugwiseThingHandler.java @@ -164,6 +164,7 @@ public abstract class AbstractPlugwiseThingHandler extends BaseThingHandler impl } protected boolean recentlySendConfigurationUpdate() { + LocalDateTime lastConfigurationUpdateSend = this.lastConfigurationUpdateSend; return lastConfigurationUpdateSend != null && LocalDateTime.now().minus(Duration.ofMillis(500)).isBefore(lastConfigurationUpdateSend); } diff --git a/bundles/org.openhab.binding.pulseaudio/src/main/java/org/openhab/binding/pulseaudio/internal/cli/Parser.java b/bundles/org.openhab.binding.pulseaudio/src/main/java/org/openhab/binding/pulseaudio/internal/cli/Parser.java index 9284011b7..2c493fe5e 100644 --- a/bundles/org.openhab.binding.pulseaudio/src/main/java/org/openhab/binding/pulseaudio/internal/cli/Parser.java +++ b/bundles/org.openhab.binding.pulseaudio/src/main/java/org/openhab/binding/pulseaudio/internal/cli/Parser.java @@ -265,10 +265,11 @@ public class Parser { source.setMuted(properties.get("muted").equalsIgnoreCase("yes")); } if (properties.containsKey("volume")) { - source.setVolume(Integer.valueOf(parseVolume(properties.get("volume")))); + source.setVolume(parseVolume(properties.get("volume"))); } - if (properties.containsKey("monitor_of")) { - source.setMonitorOf(client.getSink(Integer.valueOf(properties.get("monitor_of")))); + String monitorOf = properties.get("monitor_of"); + if (monitorOf != null) { + source.setMonitorOf(client.getSink(Integer.valueOf(monitorOf))); } sources.add(source); } diff --git a/bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/communication/RadioThermostatConnector.java b/bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/communication/RadioThermostatConnector.java index e46b9b524..abcf0adf3 100644 --- a/bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/communication/RadioThermostatConnector.java +++ b/bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/communication/RadioThermostatConnector.java @@ -152,6 +152,10 @@ public class RadioThermostatConnector { * @return a valid URL for the thermostat's JSON interface */ private String buildRequestURL(String resource) { + String hostName = this.hostName; + if (hostName == null) { + throw new IllegalStateException("hostname must not be null"); + } String urlStr = URL.replace("%hostName%", hostName); urlStr = urlStr.replace("%resource%", resource); diff --git a/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/exceptions/RemoteopenhabException.java b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/exceptions/RemoteopenhabException.java index 2f8d2dd4a..7b63add9e 100644 --- a/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/exceptions/RemoteopenhabException.java +++ b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/exceptions/RemoteopenhabException.java @@ -13,6 +13,7 @@ package org.openhab.binding.remoteopenhab.internal.exceptions; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * Exceptions thrown by this binding. @@ -23,15 +24,15 @@ import org.eclipse.jdt.annotation.NonNullByDefault; @SuppressWarnings("serial") public class RemoteopenhabException extends Exception { - public RemoteopenhabException(String message) { + public RemoteopenhabException(@Nullable String message) { super(message); } - public RemoteopenhabException(String message, Throwable cause) { + public RemoteopenhabException(@Nullable String message, @Nullable Throwable cause) { super(message, cause); } - public RemoteopenhabException(Throwable cause) { + public RemoteopenhabException(@Nullable Throwable cause) { super(cause); } } diff --git a/bundles/org.openhab.binding.sagercaster/src/main/java/org/openhab/binding/sagercaster/internal/handler/ExpiringMap.java b/bundles/org.openhab.binding.sagercaster/src/main/java/org/openhab/binding/sagercaster/internal/handler/ExpiringMap.java index 10322902c..4c2bfee85 100644 --- a/bundles/org.openhab.binding.sagercaster/src/main/java/org/openhab/binding/sagercaster/internal/handler/ExpiringMap.java +++ b/bundles/org.openhab.binding.sagercaster/src/main/java/org/openhab/binding/sagercaster/internal/handler/ExpiringMap.java @@ -39,7 +39,7 @@ class ExpiringMap { values.put(now, newValue); Optional eldestKey = values.keySet().stream().filter(key -> key < now - eldestAge).findFirst(); if (eldestKey.isPresent()) { - agedValue = Optional.of(values.get(eldestKey.get())); + agedValue = Optional.ofNullable(values.get(eldestKey.get())); values.entrySet().removeIf(map -> map.getKey() <= eldestKey.get()); } } diff --git a/bundles/org.openhab.binding.samsungtv/src/main/java/org/openhab/binding/samsungtv/internal/service/MediaRendererService.java b/bundles/org.openhab.binding.samsungtv/src/main/java/org/openhab/binding/samsungtv/internal/service/MediaRendererService.java index bf524e70f..21c5ae3d1 100644 --- a/bundles/org.openhab.binding.samsungtv/src/main/java/org/openhab/binding/samsungtv/internal/service/MediaRendererService.java +++ b/bundles/org.openhab.binding.samsungtv/src/main/java/org/openhab/binding/samsungtv/internal/service/MediaRendererService.java @@ -248,7 +248,7 @@ public class MediaRendererService implements UpnpIOParticipant, SamsungTvService try { newValue = DataConverters.convertCommandToIntValue(command, 0, 100, - Integer.valueOf(stateMap.get("CurrentVolume"))); + Integer.valueOf(stateMap.getOrDefault("CurrentVolume", ""))); } catch (NumberFormatException e) { throw new NumberFormatException("Command '" + command + "' not supported"); } @@ -281,7 +281,7 @@ public class MediaRendererService implements UpnpIOParticipant, SamsungTvService try { newValue = DataConverters.convertCommandToIntValue(command, 0, 100, - Integer.valueOf(stateMap.get("CurrentBrightness"))); + Integer.valueOf(stateMap.getOrDefault("CurrentBrightness", ""))); } catch (NumberFormatException e) { throw new NumberFormatException("Command '" + command + "' not supported"); } @@ -297,7 +297,7 @@ public class MediaRendererService implements UpnpIOParticipant, SamsungTvService try { newValue = DataConverters.convertCommandToIntValue(command, 0, 100, - Integer.valueOf(stateMap.get("CurrentContrast"))); + Integer.valueOf(stateMap.getOrDefault("CurrentContrast", ""))); } catch (NumberFormatException e) { throw new NumberFormatException("Command '" + command + "' not supported"); } @@ -313,7 +313,7 @@ public class MediaRendererService implements UpnpIOParticipant, SamsungTvService try { newValue = DataConverters.convertCommandToIntValue(command, 0, 100, - Integer.valueOf(stateMap.get("CurrentSharpness"))); + Integer.valueOf(stateMap.getOrDefault("CurrentSharpness", ""))); } catch (NumberFormatException e) { throw new NumberFormatException("Command '" + command + "' not supported"); } @@ -329,7 +329,7 @@ public class MediaRendererService implements UpnpIOParticipant, SamsungTvService try { newValue = DataConverters.convertCommandToIntValue(command, 0, 4, - Integer.valueOf(stateMap.get("CurrentColorTemperature"))); + Integer.valueOf(stateMap.getOrDefault("CurrentColorTemperature", ""))); } catch (NumberFormatException e) { throw new NumberFormatException("Command '" + command + "' not supported"); } diff --git a/bundles/org.openhab.binding.samsungtv/src/main/java/org/openhab/binding/samsungtv/internal/service/ServiceFactory.java b/bundles/org.openhab.binding.samsungtv/src/main/java/org/openhab/binding/samsungtv/internal/service/ServiceFactory.java index a709aac9a..66b700d95 100644 --- a/bundles/org.openhab.binding.samsungtv/src/main/java/org/openhab/binding/samsungtv/internal/service/ServiceFactory.java +++ b/bundles/org.openhab.binding.samsungtv/src/main/java/org/openhab/binding/samsungtv/internal/service/ServiceFactory.java @@ -86,7 +86,7 @@ public class ServiceFactory { * @param serviceName Name of the service * @return Class of the service */ - public static Class getClassByServiceName(String serviceName) { + public static @Nullable Class getClassByServiceName(String serviceName) { return SERVICEMAP.get(serviceName); } } diff --git a/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/action/SatelEventLogActions.java b/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/action/SatelEventLogActions.java index f3ea9699e..be8cb0808 100644 --- a/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/action/SatelEventLogActions.java +++ b/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/action/SatelEventLogActions.java @@ -59,6 +59,7 @@ public class SatelEventLogActions implements ThingActions { logger.debug("satel.readEvent called with input: index={}", index); Map result = new HashMap<>(); + SatelEventLogHandler handler = this.handler; if (handler != null) { handler.readEvent(index == null ? -1 : index.intValue()).ifPresent(event -> { result.put("index", event.getIndex()); diff --git a/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/SatelThingHandler.java b/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/SatelThingHandler.java index 4f9928955..0735382cb 100644 --- a/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/SatelThingHandler.java +++ b/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/SatelThingHandler.java @@ -58,8 +58,8 @@ public abstract class SatelThingHandler extends BaseThingHandler implements Sate if (bridge != null) { final ThingHandler handler = bridge.getHandler(); if (handler != null && handler instanceof SatelBridgeHandler) { + ((SatelBridgeHandler) handler).addEventListener(this); this.bridgeHandler = (SatelBridgeHandler) handler; - this.bridgeHandler.addEventListener(this); } if (bridge.getStatus() == ThingStatus.ONLINE) { updateStatus(ThingStatus.ONLINE); diff --git a/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/protocol/SatelModule.java b/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/protocol/SatelModule.java index 224b8adc3..20e272725 100644 --- a/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/protocol/SatelModule.java +++ b/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/protocol/SatelModule.java @@ -351,8 +351,8 @@ public abstract class SatelModule extends EventDispatcher implements SatelEventL private synchronized void disconnect(@Nullable String reason) { // remove all pending commands from the queue // notifying about send failure - while (!this.sendQueue.isEmpty()) { - SatelCommand cmd = this.sendQueue.poll(); + SatelCommand cmd; + while ((cmd = this.sendQueue.poll()) != null) { cmd.setState(State.FAILED); } final CommunicationChannel channel = this.channel; @@ -503,13 +503,13 @@ public abstract class SatelModule extends EventDispatcher implements SatelEventL } private void startCommunication() { - final Thread thread = this.thread; + Thread thread = this.thread; if (thread != null && thread.isAlive()) { logger.error("Start communication canceled: communication thread is still alive"); return; } // start new thread - this.thread = new Thread(new Runnable() { + thread = new Thread(new Runnable() { @Override public void run() { logger.debug("Communication thread started"); @@ -517,7 +517,8 @@ public abstract class SatelModule extends EventDispatcher implements SatelEventL logger.debug("Communication thread stopped"); } }); - this.thread.start(); + thread.start(); + this.thread = thread; // if module is not initialized yet, send version command if (!SatelModule.this.isInitialized()) { SatelModule.this.sendCommand(new IntegraVersionCommand()); diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyApiException.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyApiException.java index 1f7f42dbc..f1e5a4457 100644 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyApiException.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyApiException.java @@ -59,7 +59,7 @@ public class ShellyApiException extends Exception { } @Override - public String getMessage() { + public @Nullable String getMessage() { return isEmpty() ? "" : nonNullString(super.getMessage()); } diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/coap/ShellyCoIoTProtocol.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/coap/ShellyCoIoTProtocol.java index 08a4d02ae..fcf633c5f 100644 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/coap/ShellyCoIoTProtocol.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/coap/ShellyCoIoTProtocol.java @@ -235,7 +235,7 @@ public class ShellyCoIoTProtocol { Double brightness = -1.0; Double power = -1.0; for (CoIotSensor update : allUpdates) { - CoIotDescrSen d = fixDescription(sensorMap.get(update.id), blkMap); + CoIotDescrSen d = fixDescription(sensorMap.getOrDefault(update.id, new CoIotDescrSen()), blkMap); if (!checkL.isEmpty() && !d.links.equals(checkL)) { // continue until we find the correct one continue; diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java index 2f2314634..b4e823360 100644 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java @@ -124,12 +124,13 @@ public class ShellyThingCreator { } // Check general mapping - if (!deviceType.isEmpty() && THING_TYPE_MAPPING.containsKey(deviceType)) { - return THING_TYPE_MAPPING.get(deviceType); + if (!deviceType.isEmpty()) { + String str = THING_TYPE_MAPPING.get(deviceType); + if (str != null) { + return str; + } } - if (THING_TYPE_MAPPING.containsKey(type)) { - return THING_TYPE_MAPPING.get(type); - } - return THING_TYPE_SHELLYUNKNOWN_STR; + + return THING_TYPE_MAPPING.getOrDefault(type, THING_TYPE_SHELLYUNKNOWN_STR); } } diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/util/ShellyChannelCache.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/util/ShellyChannelCache.java index a92119a4f..3aa0bb0c7 100644 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/util/ShellyChannelCache.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/util/ShellyChannelCache.java @@ -120,10 +120,7 @@ public class ShellyChannelCache { } public State getValue(String channelId) { - if (channelData.containsKey(channelId)) { - return channelData.get(channelId); - } - return UnDefType.NULL; + return channelData.getOrDefault(channelId, UnDefType.NULL); } public void resetChannel(String channelId) { diff --git a/bundles/org.openhab.binding.siemensrds/src/main/java/org/openhab/binding/siemensrds/points/BasePoint.java b/bundles/org.openhab.binding.siemensrds/src/main/java/org/openhab/binding/siemensrds/points/BasePoint.java index 09ecde9ad..1e8e387e0 100644 --- a/bundles/org.openhab.binding.siemensrds/src/main/java/org/openhab/binding/siemensrds/points/BasePoint.java +++ b/bundles/org.openhab.binding.siemensrds/src/main/java/org/openhab/binding/siemensrds/points/BasePoint.java @@ -70,7 +70,7 @@ public abstract class BasePoint { @SerializedName("presentPriority") protected int presentPriority; - private @Nullable String @Nullable [] enumVals; + private String @Nullable [] enumVals; private boolean enumParsed = false; protected boolean isEnum = false; diff --git a/bundles/org.openhab.binding.siemensrds/src/main/java/org/openhab/binding/siemensrds/points/StringPoint.java b/bundles/org.openhab.binding.siemensrds/src/main/java/org/openhab/binding/siemensrds/points/StringPoint.java index 1124a461c..1d722c00c 100644 --- a/bundles/org.openhab.binding.siemensrds/src/main/java/org/openhab/binding/siemensrds/points/StringPoint.java +++ b/bundles/org.openhab.binding.siemensrds/src/main/java/org/openhab/binding/siemensrds/points/StringPoint.java @@ -34,10 +34,14 @@ public class StringPoint extends BasePoint { @Override public int asInt() { try { - return Integer.parseInt(value); - } catch (Exception e) { - return UNDEFINED_VALUE; + String value = this.value; + if (value != null) { + return Integer.parseInt(value); + } + } catch (NumberFormatException e) { + // default value } + return UNDEFINED_VALUE; } @Override diff --git a/bundles/org.openhab.binding.smartmeter/src/main/java/org/openhab/binding/smartmeter/internal/conformity/Conformity.java b/bundles/org.openhab.binding.smartmeter/src/main/java/org/openhab/binding/smartmeter/internal/conformity/Conformity.java index c0e0213dc..91c691d9b 100644 --- a/bundles/org.openhab.binding.smartmeter/src/main/java/org/openhab/binding/smartmeter/internal/conformity/Conformity.java +++ b/bundles/org.openhab.binding.smartmeter/src/main/java/org/openhab/binding/smartmeter/internal/conformity/Conformity.java @@ -113,8 +113,8 @@ public enum Conformity { boolean shouldNegateState = NegateHandler.shouldNegateState(negateProperty, channelId -> { Channel negateChannel = thing.getChannel(channelId); if (negateChannel != null) { - return device.getMeterValue( - negateChannel.getProperties().get(SmartMeterBindingConstants.CHANNEL_PROPERTY_OBIS)); + String property = negateChannel.getProperties().get(SmartMeterBindingConstants.CHANNEL_PROPERTY_OBIS); + return property != null ? device.getMeterValue(property) : null; } return null; }); diff --git a/bundles/org.openhab.binding.smartthings/src/main/java/org/openhab/binding/smartthings/internal/converter/SmartthingsHue100Converter.java b/bundles/org.openhab.binding.smartthings/src/main/java/org/openhab/binding/smartthings/internal/converter/SmartthingsHue100Converter.java index b83f311a9..080bd76a2 100644 --- a/bundles/org.openhab.binding.smartthings/src/main/java/org/openhab/binding/smartthings/internal/converter/SmartthingsHue100Converter.java +++ b/bundles/org.openhab.binding.smartthings/src/main/java/org/openhab/binding/smartthings/internal/converter/SmartthingsHue100Converter.java @@ -73,7 +73,7 @@ public class SmartthingsHue100Converter extends SmartthingsConverter { return UnDefType.UNDEF; } - if ("Number".contentEquals(acceptedChannelType)) { + if (acceptedChannelType != null && "Number".contentEquals(acceptedChannelType)) { if (deviceValue instanceof String) { double d = Double.parseDouble((String) deviceValue); d *= 3.6; diff --git a/bundles/org.openhab.binding.snmp/src/test/java/org/openhab/binding/snmp/internal/AbstractSnmpTargetHandlerTest.java b/bundles/org.openhab.binding.snmp/src/test/java/org/openhab/binding/snmp/internal/AbstractSnmpTargetHandlerTest.java index 01f059515..1c00872dc 100644 --- a/bundles/org.openhab.binding.snmp/src/test/java/org/openhab/binding/snmp/internal/AbstractSnmpTargetHandlerTest.java +++ b/bundles/org.openhab.binding.snmp/src/test/java/org/openhab/binding/snmp/internal/AbstractSnmpTargetHandlerTest.java @@ -146,7 +146,7 @@ public abstract class AbstractSnmpTargetHandlerTest extends JavaTest { if (refresh) { ArgumentCaptor pduCaptor = ArgumentCaptor.forClass(PDU.class); - verify(snmpService, atLeast(1)).send(pduCaptor.capture(), any(), eq(null), eq(thingHandler)); + verify(snmpService, timeout(500).atLeast(1)).send(pduCaptor.capture(), any(), eq(null), eq(thingHandler)); Vector variables = pduCaptor.getValue().getVariableBindings(); assertTrue(variables.stream().filter(v -> v.getOid().toDottedString().equals(TEST_OID)).findFirst() .isPresent()); diff --git a/bundles/org.openhab.binding.solaredge/src/main/java/org/openhab/binding/solaredge/internal/connector/CommunicationStatus.java b/bundles/org.openhab.binding.solaredge/src/main/java/org/openhab/binding/solaredge/internal/connector/CommunicationStatus.java index db877ec8d..25673f36a 100644 --- a/bundles/org.openhab.binding.solaredge/src/main/java/org/openhab/binding/solaredge/internal/connector/CommunicationStatus.java +++ b/bundles/org.openhab.binding.solaredge/src/main/java/org/openhab/binding/solaredge/internal/connector/CommunicationStatus.java @@ -48,8 +48,11 @@ public class CommunicationStatus { public final String getMessage() { Code httpCode = this.httpCode; Exception error = this.error; - if (error != null && error.getMessage() != null && !error.getMessage().isEmpty()) { - return error.getMessage(); + if (error != null) { + String message = error.getMessage(); + if (message != null && !message.isEmpty()) { + return message; + } } else if (httpCode != null && httpCode.getMessage() != null && !httpCode.getMessage().isEmpty()) { return httpCode.getMessage(); } diff --git a/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosXMLParser.java b/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosXMLParser.java index ce04c67f5..4f9665e96 100644 --- a/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosXMLParser.java +++ b/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosXMLParser.java @@ -328,7 +328,7 @@ public class SonosXMLParser { @Override public void characters(char @Nullable [] ch, int start, int length) throws SAXException { Element elt = element; - if (elt == null) { + if (elt == null || ch == null) { return; } switch (elt) { @@ -446,7 +446,7 @@ public class SonosXMLParser { @Override public void characters(char @Nullable [] ch, int start, int length) throws SAXException { Element elt = element; - if (elt == null) { + if (elt == null || ch == null) { return; } switch (elt) { @@ -530,9 +530,17 @@ public class SonosXMLParser { boolean finalIncludeLinkedZones = !"0".equals(includeLinkedZones); try { + String id = this.id; + if (id == null) { + throw new NumberFormatException(); + } finalID = Integer.parseInt(id); + String volume = this.volume; + if (volume == null) { + throw new NumberFormatException(); + } finalVolume = Integer.parseInt(volume); - } catch (Exception e) { + } catch (NumberFormatException e) { LOGGER.debug("Error parsing Integer"); } @@ -790,7 +798,7 @@ public class SonosXMLParser { @Override public void characters(char @Nullable [] ch, int start, int length) throws SAXException { CurrentElement elt = currentElement; - if (elt == null) { + if (elt == null || ch == null) { return; } switch (elt) { @@ -875,7 +883,7 @@ public class SonosXMLParser { @Override public void characters(char @Nullable [] ch, int start, int length) throws SAXException { - if (getPresetName) { + if (getPresetName && ch != null) { presetName = new String(ch, start, length); } } @@ -944,7 +952,7 @@ public class SonosXMLParser { @Override public void characters(char @Nullable [] ch, int start, int length) throws SAXException { - if (roomNameTag) { + if (roomNameTag && ch != null) { roomName = new String(ch, start, length); roomNameTag = false; } @@ -983,7 +991,7 @@ public class SonosXMLParser { @Override public void characters(char @Nullable [] ch, int start, int length) throws SAXException { - if (modelNameTag) { + if (modelNameTag && ch != null) { modelName = new String(ch, start, length); modelNameTag = false; } diff --git a/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler/ZonePlayerHandler.java b/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler/ZonePlayerHandler.java index 7f73e186e..25b5d358f 100644 --- a/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler/ZonePlayerHandler.java +++ b/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler/ZonePlayerHandler.java @@ -1393,7 +1393,11 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici } try { - result = Long.valueOf(resultInput.get(requestedKey)); + String resultString = resultInput.get(requestedKey); + if (resultString == null) { + throw new NumberFormatException("Requested key is null."); + } + result = Long.valueOf(resultString); } catch (NumberFormatException ex) { logger.debug("Could not fetch {} result for type: {} and filter: {}. Using default value '0': {}", requestedKey, entriesType, entriesFilter, ex.getMessage(), ex); diff --git a/bundles/org.openhab.binding.sonyprojector/src/main/java/org/openhab/binding/sonyprojector/internal/SonyProjectorException.java b/bundles/org.openhab.binding.sonyprojector/src/main/java/org/openhab/binding/sonyprojector/internal/SonyProjectorException.java index b37441d35..c3b0246ff 100644 --- a/bundles/org.openhab.binding.sonyprojector/src/main/java/org/openhab/binding/sonyprojector/internal/SonyProjectorException.java +++ b/bundles/org.openhab.binding.sonyprojector/src/main/java/org/openhab/binding/sonyprojector/internal/SonyProjectorException.java @@ -13,6 +13,7 @@ package org.openhab.binding.sonyprojector.internal; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * The {@link SonyProjectorException} class is used for any exception thrown by the binding @@ -28,7 +29,7 @@ public class SonyProjectorException extends Exception { } // Constructor that accepts a message - public SonyProjectorException(String message) { + public SonyProjectorException(@Nullable String message) { super(message); } } diff --git a/bundles/org.openhab.binding.spotify/src/main/java/org/openhab/binding/spotify/internal/api/SpotifyConnector.java b/bundles/org.openhab.binding.spotify/src/main/java/org/openhab/binding/spotify/internal/api/SpotifyConnector.java index d03843e2d..f61dc915a 100644 --- a/bundles/org.openhab.binding.spotify/src/main/java/org/openhab/binding/spotify/internal/api/SpotifyConnector.java +++ b/bundles/org.openhab.binding.spotify/src/main/java/org/openhab/binding/spotify/internal/api/SpotifyConnector.java @@ -149,7 +149,12 @@ class SpotifyConnector { } } } catch (ExecutionException e) { - future.completeExceptionally(e.getCause()); + Throwable cause = e.getCause(); + if (cause != null) { + future.completeExceptionally(cause); + } else { + future.completeExceptionally(e); + } } catch (RuntimeException | TimeoutException e) { future.completeExceptionally(e); } catch (InterruptedException e) { diff --git a/bundles/org.openhab.binding.spotify/src/main/java/org/openhab/binding/spotify/internal/handler/SpotifyBridgeHandler.java b/bundles/org.openhab.binding.spotify/src/main/java/org/openhab/binding/spotify/internal/handler/SpotifyBridgeHandler.java index bd12ddc56..ee16d7616 100644 --- a/bundles/org.openhab.binding.spotify/src/main/java/org/openhab/binding/spotify/internal/handler/SpotifyBridgeHandler.java +++ b/bundles/org.openhab.binding.spotify/src/main/java/org/openhab/binding/spotify/internal/handler/SpotifyBridgeHandler.java @@ -218,7 +218,7 @@ public class SpotifyBridgeHandler extends BaseBridgeHandler @Override public String getUser() { - return thing.getProperties().get(PROPERTY_SPOTIFY_USER); + return thing.getProperties().getOrDefault(PROPERTY_SPOTIFY_USER, ""); } @Override diff --git a/bundles/org.openhab.binding.squeezebox/src/main/java/org/openhab/binding/squeezebox/internal/handler/SqueezeBoxPlayerHandler.java b/bundles/org.openhab.binding.squeezebox/src/main/java/org/openhab/binding/squeezebox/internal/handler/SqueezeBoxPlayerHandler.java index f872893dd..f8ec698af 100644 --- a/bundles/org.openhab.binding.squeezebox/src/main/java/org/openhab/binding/squeezebox/internal/handler/SqueezeBoxPlayerHandler.java +++ b/bundles/org.openhab.binding.squeezebox/src/main/java/org/openhab/binding/squeezebox/internal/handler/SqueezeBoxPlayerHandler.java @@ -189,8 +189,9 @@ public class SqueezeBoxPlayerHandler extends BaseThingHandler implements Squeeze // Some of the code below is not designed to handle REFRESH, only reply to channels where cached values exist if (command == RefreshType.REFRESH) { String channelID = channelUID.getId(); - if (stateMap.containsKey(channelID)) { - updateState(channelID, stateMap.get(channelID)); + State newState = stateMap.get(channelID); + if (newState != null) { + updateState(channelID, newState); } return; } diff --git a/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/TACmiChannelTypeProvider.java b/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/TACmiChannelTypeProvider.java index 74036683e..d9bf61a53 100644 --- a/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/TACmiChannelTypeProvider.java +++ b/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/TACmiChannelTypeProvider.java @@ -46,7 +46,7 @@ public class TACmiChannelTypeProvider implements ChannelTypeProvider { return channelTypesByUID.get(channelTypeUID); } - public ChannelType getInternalChannelType(ChannelTypeUID channelTypeUID) { + public @Nullable ChannelType getInternalChannelType(ChannelTypeUID channelTypeUID) { return channelTypesByUID.get(channelTypeUID); } diff --git a/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ApiPageParser.java b/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ApiPageParser.java index e6eceb981..562e30098 100644 --- a/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ApiPageParser.java +++ b/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ApiPageParser.java @@ -243,13 +243,15 @@ public class ApiPageParser extends AbstractSimpleMarkupHandler { @Override public void handleComment(final char @Nullable [] buffer, final int offset, final int len, final int line, final int col) throws ParseException { - logger.debug("Unexpected comment in {}:{}: {}", line, col, new String(buffer, offset, len)); + logger.debug("Unexpected comment in {}:{}: {}", line, col, + buffer == null ? "" : new String(buffer, offset, len)); } @Override public void handleCDATASection(final char @Nullable [] buffer, final int offset, final int len, final int line, final int col) throws ParseException { - logger.debug("Unexpected CDATA in {}:{}: {}", line, col, new String(buffer, offset, len)); + logger.debug("Unexpected CDATA in {}:{}: {}", line, col, + buffer == null ? "" : new String(buffer, offset, len)); } @Override diff --git a/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ChangerX2Parser.java b/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ChangerX2Parser.java index 3270c1e5d..aeea36440 100644 --- a/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ChangerX2Parser.java +++ b/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ChangerX2Parser.java @@ -170,13 +170,15 @@ public class ChangerX2Parser extends AbstractSimpleMarkupHandler { @Override public void handleAutoCloseElement(final @Nullable String elementName, final int line, final int col) throws ParseException { - logger.debug("Unexpected AutoCloseElement in {}:{}: {}", line, col, elementName); + logger.debug("Unexpected AutoCloseElement in {}:{}: {}", line, col, + elementName == null ? "" : elementName); } @Override public void handleUnmatchedCloseElement(final @Nullable String elementName, final int line, final int col) throws ParseException { - logger.debug("Unexpected UnmatchedCloseElement in {}:{}: {}", line, col, elementName); + logger.debug("Unexpected UnmatchedCloseElement in {}:{}: {}", line, col, + elementName == null ? "" : elementName); } @Override @@ -190,13 +192,15 @@ public class ChangerX2Parser extends AbstractSimpleMarkupHandler { @Override public void handleComment(final char @Nullable [] buffer, final int offset, final int len, final int line, final int col) throws ParseException { - logger.debug("Unexpected comment in {}:{}: {}", line, col, new String(buffer, offset, len)); + logger.debug("Unexpected comment in {}:{}: {}", line, col, + buffer == null ? "" : new String(buffer, offset, len)); } @Override public void handleCDATASection(final char @Nullable [] buffer, final int offset, final int len, final int line, final int col) throws ParseException { - logger.debug("Unexpected CDATA in {}:{}: {}", line, col, new String(buffer, offset, len)); + logger.debug("Unexpected CDATA in {}:{}: {}", line, col, + buffer == null ? "" : new String(buffer, offset, len)); } @Override diff --git a/bundles/org.openhab.binding.telegram/src/main/java/org/openhab/binding/telegram/internal/TelegramHandler.java b/bundles/org.openhab.binding.telegram/src/main/java/org/openhab/binding/telegram/internal/TelegramHandler.java index e28432b72..025bc8de7 100644 --- a/bundles/org.openhab.binding.telegram/src/main/java/org/openhab/binding/telegram/internal/TelegramHandler.java +++ b/bundles/org.openhab.binding.telegram/src/main/java/org/openhab/binding/telegram/internal/TelegramHandler.java @@ -408,7 +408,7 @@ public class TelegramHandler extends BaseThingHandler { return replyIdToCallbackId.get(new ReplyKey(chatId, replyId)); } - public Integer removeMessageId(Long chatId, String replyId) { + public @Nullable Integer removeMessageId(Long chatId, String replyId) { return replyIdToMessageId.remove(new ReplyKey(chatId, replyId)); } diff --git a/bundles/org.openhab.binding.telegram/src/main/java/org/openhab/binding/telegram/internal/action/TelegramActions.java b/bundles/org.openhab.binding.telegram/src/main/java/org/openhab/binding/telegram/internal/action/TelegramActions.java index e155d6b52..a0412d5a8 100644 --- a/bundles/org.openhab.binding.telegram/src/main/java/org/openhab/binding/telegram/internal/action/TelegramActions.java +++ b/bundles/org.openhab.binding.telegram/src/main/java/org/openhab/binding/telegram/internal/action/TelegramActions.java @@ -255,6 +255,9 @@ public class TelegramActions implements ThingActions { public boolean sendTelegram(@ActionInput(name = "chatId") @Nullable Long chatId, @ActionInput(name = "message") @Nullable String message, @ActionInput(name = "args") @Nullable Object... args) { + if (message == null) { + return false; + } return sendTelegram(chatId, String.format(message, args)); } @@ -444,7 +447,14 @@ public class TelegramActions implements ThingActions { public static boolean sendTelegramAnswer(ThingActions actions, @Nullable String chatId, @Nullable String replyId, @Nullable String message) { - return ((TelegramActions) actions).sendTelegramAnswer(Long.valueOf(chatId), replyId, message); + if (actions instanceof TelegramActions) { + if (chatId == null) { + return false; + } + return ((TelegramActions) actions).sendTelegramAnswer(Long.valueOf(chatId), replyId, message); + } else { + throw new IllegalArgumentException("Actions is not an instance of TelegramActions"); + } } @Override diff --git a/bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/handler/TibberHandler.java b/bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/handler/TibberHandler.java index 67df80192..6c8f024be 100644 --- a/bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/handler/TibberHandler.java +++ b/bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/handler/TibberHandler.java @@ -416,8 +416,9 @@ public class TibberHandler extends BaseThingHandler { @OnWebSocketError public void onWebSocketError(Throwable e) { - logger.debug("Error during websocket communication: {}", e.getMessage()); - onClose(0, e.getMessage()); + String message = e.getMessage(); + logger.debug("Error during websocket communication: {}", message); + onClose(0, message != null ? message : "null"); } @OnWebSocketMessage diff --git a/bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/TouchWandBaseUnitHandler.java b/bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/TouchWandBaseUnitHandler.java index d1b1de3dc..61703e536 100644 --- a/bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/TouchWandBaseUnitHandler.java +++ b/bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/TouchWandBaseUnitHandler.java @@ -85,7 +85,12 @@ public abstract class TouchWandBaseUnitHandler extends BaseThingHandler implemen bridgeHandler = (TouchWandBridgeHandler) bridge.getHandler(); - unitId = getThing().getProperties().get(HANDLER_PROPERTIES_ID); // TouchWand unit id + String unitId = getThing().getProperties().get(HANDLER_PROPERTIES_ID); // TouchWand unit id + if (unitId == null) { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "unitID missing"); + return; + } + this.unitId = unitId; TouchWandBridgeHandler myTmpBridgeHandler = bridgeHandler; if (myTmpBridgeHandler != null) { diff --git a/bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/UpnpXMLParser.java b/bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/UpnpXMLParser.java index 2f46a5bcf..f98318029 100644 --- a/bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/UpnpXMLParser.java +++ b/bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/UpnpXMLParser.java @@ -262,7 +262,7 @@ public class UpnpXMLParser { @Override public void characters(char @Nullable [] ch, int start, int length) throws SAXException { Element el = element; - if (el == null) { + if (el == null || ch == null) { return; } switch (el) { diff --git a/bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/handler/UpnpHandler.java b/bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/handler/UpnpHandler.java index c9c93687f..ee5a34833 100644 --- a/bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/handler/UpnpHandler.java +++ b/bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/handler/UpnpHandler.java @@ -165,12 +165,12 @@ public abstract class UpnpHandler extends BaseThingHandler implements UpnpIOPart @Override public void onValueReceived(@Nullable String variable, @Nullable String value, @Nullable String service) { - if (variable == null) { + if (variable == null || value == null) { return; } switch (variable) { case "CurrentTransportState": - if (!((value == null) || (value.isEmpty()))) { + if (!value.isEmpty()) { transportState = value; } break; diff --git a/bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/handler/UpnpRendererHandler.java b/bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/handler/UpnpRendererHandler.java index 3443c03b7..3bbe561a7 100644 --- a/bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/handler/UpnpRendererHandler.java +++ b/bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/handler/UpnpRendererHandler.java @@ -590,7 +590,7 @@ public class UpnpRendererHandler extends UpnpHandler { playing = true; updateState(CONTROL, PlayPauseType.PLAY); scheduleTrackPositionRefresh(); - } else if ("PAUSED_PLAYBACK".contentEquals(value)) { + } else if ("PAUSED_PLAYBACK".equals(value)) { updateState(CONTROL, PlayPauseType.PAUSE); } break; diff --git a/bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/handler/UpnpServerHandler.java b/bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/handler/UpnpServerHandler.java index db1eacb48..1b5715a4b 100644 --- a/bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/handler/UpnpServerHandler.java +++ b/bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/handler/UpnpServerHandler.java @@ -207,7 +207,13 @@ public class UpnpServerHandler extends UpnpHandler { // No parent found, so make it the root directory browseTarget = DIRECTORY_ROOT; } - currentEntry = parentMap.get(browseTarget); + UpnpEntry entry = parentMap.get(browseTarget); + if (entry == null) { + logger.info("Browse target not found. Exiting."); + return; + } + currentEntry = entry; + } updateState(CURRENTID, StringType.valueOf(currentEntry.getId())); logger.debug("Browse target {}", browseTarget); @@ -349,8 +355,8 @@ public class UpnpServerHandler extends UpnpHandler { } /** - * Method that does a UPnP browse on a content directory. Results will be retrieved in the {@link onValueReceived} - * method. + * Method that does a UPnP browse on a content directory. Results will be retrieved in the + * {@link #onValueReceived(String, String, String)} method. * * @param objectID content directory object * @param browseFlag BrowseMetaData or BrowseDirectChildren @@ -373,8 +379,8 @@ public class UpnpServerHandler extends UpnpHandler { } /** - * Method that does a UPnP search on a content directory. Results will be retrieved in the {@link onValueReceived} - * method. + * Method that does a UPnP search on a content directory. Results will be retrieved in the + * {@link #onValueReceived(String, String, String)} method. * * @param containerID content directory container * @param searchCriteria search criteria, examples: diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/VeluxRSBindingConfig.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/VeluxRSBindingConfig.java index 493202721..60e2557d7 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/VeluxRSBindingConfig.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/VeluxRSBindingConfig.java @@ -204,6 +204,6 @@ public class VeluxRSBindingConfig extends VeluxBindingConfig { public String getSceneName(Integer level) { logger.trace("getSceneName({}) called.", level); logger.trace("getSceneName() returning {}.", mapDescending.get(level)); - return mapDescending.get(level); + return mapDescending.getOrDefault(level, "null"); } } diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxExistingProducts.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxExistingProducts.java index bfcd09836..9f277ed1e 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxExistingProducts.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxExistingProducts.java @@ -86,10 +86,8 @@ public class VeluxExistingProducts { public boolean isRegistered(ProductBridgeIndex bridgeProductIndex) { logger.trace("isRegisteredProductBridgeIndex {}) called.", bridgeProductIndex.toString()); - if (!bridgeIndexToSerialNumber.containsKey(bridgeProductIndex.toInt())) { - return false; - } - return isRegistered(bridgeIndexToSerialNumber.get(bridgeProductIndex.toInt())); + String serialNumber = bridgeIndexToSerialNumber.get(bridgeProductIndex.toInt()); + return serialNumber != null && isRegistered(serialNumber); } public boolean register(VeluxProduct newProduct) { @@ -148,15 +146,16 @@ public class VeluxExistingProducts { if (!isRegistered(productUniqueIndexOrSerialNumber)) { return VeluxProduct.UNKNOWN; } - return existingProductsByUniqueIndex.get(productUniqueIndexOrSerialNumber); + return existingProductsByUniqueIndex.getOrDefault(productUniqueIndexOrSerialNumber, VeluxProduct.UNKNOWN); } public VeluxProduct get(ProductBridgeIndex bridgeProductIndex) { logger.trace("get({}) called.", bridgeProductIndex); - if (!isRegistered(bridgeProductIndex)) { + String serialNumber = bridgeIndexToSerialNumber.get(bridgeProductIndex.toInt()); + if (!isRegistered(bridgeProductIndex) || serialNumber == null) { return VeluxProduct.UNKNOWN; } - return existingProductsByUniqueIndex.get(bridgeIndexToSerialNumber.get(bridgeProductIndex.toInt())); + return existingProductsByUniqueIndex.getOrDefault(serialNumber, VeluxProduct.UNKNOWN); } public VeluxProduct[] values() { diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxExistingScenes.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxExistingScenes.java index 217b86f75..2563e414b 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxExistingScenes.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxExistingScenes.java @@ -84,7 +84,7 @@ public class VeluxExistingScenes { if (!isRegistered(sceneName)) { return VeluxScene.UNKNOWN; } - return existingScenesBySceneName.get(sceneName.toString()); + return existingScenesBySceneName.getOrDefault(sceneName.toString(), VeluxScene.UNKNOWN); } public VeluxScene[] values() { diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxGwState.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxGwState.java index 8936beebb..56e10b6d0 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxGwState.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxGwState.java @@ -135,11 +135,7 @@ public class VeluxGwState { } public static VeluxGatewaySubState get(int stateValue) { - if (LOOKUPTYPEID2ENUM.containsKey(stateValue)) { - return LOOKUPTYPEID2ENUM.get(stateValue); - } else { - return VeluxGatewaySubState.UNDEFTYPE; - } + return LOOKUPTYPEID2ENUM.getOrDefault(stateValue, VeluxGatewaySubState.UNDEFTYPE); } } diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxKLFAPI.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxKLFAPI.java index e996293cf..d39da7b9b 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxKLFAPI.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxKLFAPI.java @@ -343,11 +343,7 @@ public class VeluxKLFAPI { } public static Command get(short thisTypeId) { - if (LOOKUPTYPEID2ENUM.containsKey(thisTypeId)) { - return LOOKUPTYPEID2ENUM.get(thisTypeId); - } else { - return Command.UNDEFTYPE; - } + return LOOKUPTYPEID2ENUM.getOrDefault(thisTypeId, Command.UNDEFTYPE); } } } diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/handler/VenstarThermostatHandler.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/handler/VenstarThermostatHandler.java index ba98283a4..a6675bb00 100644 --- a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/handler/VenstarThermostatHandler.java +++ b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/handler/VenstarThermostatHandler.java @@ -341,7 +341,8 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler { } } catch (VenstarCommunicationException | JsonSyntaxException e) { log.debug("Unable to fetch info data", e); - goOffline(ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage()); + String message = e.getMessage(); + goOffline(ThingStatusDetail.COMMUNICATION_ERROR, message != null ? message : ""); } catch (VenstarAuthenticationException e) { goOffline(ThingStatusDetail.CONFIGURATION_ERROR, "Authorization Failed"); } @@ -376,7 +377,8 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler { goOnline(); } catch (VenstarCommunicationException | JsonSyntaxException e) { log.debug("Unable to fetch info data", e); - goOffline(ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage()); + String message = e.getMessage(); + goOffline(ThingStatusDetail.COMMUNICATION_ERROR, message != null ? message : ""); } catch (VenstarAuthenticationException e) { goOffline(ThingStatusDetail.CONFIGURATION_ERROR, "Authorization Failed"); } diff --git a/bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureEventLogThingHandler.java b/bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureEventLogThingHandler.java index 406f5216e..24eeb7802 100644 --- a/bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureEventLogThingHandler.java +++ b/bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureEventLogThingHandler.java @@ -151,7 +151,12 @@ public class VerisureEventLogThingHandler extends VerisureThingHandler events = new ArrayList<>(); for (PagedList newEvent : newEventList) { - long eventTime = ZonedDateTime.parse(newEvent.getEventTime()).toEpochSecond(); + String eventTimeString = newEvent.getEventTime(); + if (eventTimeString == null) { + logger.debug("Event-Time is null: {}", newEvent); + continue; + } + long eventTime = ZonedDateTime.parse(eventTimeString).toEpochSecond(); logger.trace("Event time: {} Last Event time: {}", eventTime, lastEventTime); if (eventTime > lastEventTime) { logger.debug("Create event {} for event time {}", newEvent.getEventType(), eventTime); diff --git a/bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureGatewayThingHandler.java b/bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureGatewayThingHandler.java index 97a3e3660..36a3331aa 100644 --- a/bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureGatewayThingHandler.java +++ b/bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureGatewayThingHandler.java @@ -67,8 +67,9 @@ public class VerisureGatewayThingHandler extends VerisureThingHandler getDurationInMinutes() { + Temporal start = startTime; + Temporal end = endTime; + if (start == null || end == null) { + return Optional.empty(); + } else { + return Optional.of(Duration.between(start, end).toMinutes()); + } } public Optional getFuelConsumption() { diff --git a/bundles/org.openhab.binding.volvooncall/src/main/java/org/openhab/binding/volvooncall/internal/handler/VehicleHandler.java b/bundles/org.openhab.binding.volvooncall/src/main/java/org/openhab/binding/volvooncall/internal/handler/VehicleHandler.java index c14427db9..3a21f01b3 100644 --- a/bundles/org.openhab.binding.volvooncall/src/main/java/org/openhab/binding/volvooncall/internal/handler/VehicleHandler.java +++ b/bundles/org.openhab.binding.volvooncall/src/main/java/org/openhab/binding/volvooncall/internal/handler/VehicleHandler.java @@ -131,8 +131,9 @@ public class VehicleHandler extends BaseThingHandler { thing.getProperties().entrySet().stream().filter(p -> "true".equals(p.getValue())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))); - if (thing.getProperties().containsKey(LAST_TRIP_ID)) { - lastTripId = Long.parseLong(thing.getProperties().get(LAST_TRIP_ID)); + String lastTripIdString = thing.getProperties().get(LAST_TRIP_ID); + if (lastTripIdString != null) { + lastTripId = Long.parseLong(lastTripIdString); } updateStatus(ThingStatus.ONLINE); @@ -294,7 +295,8 @@ public class VehicleHandler extends BaseThingHandler { case TRIP_END_TIME: return tripDetails.getEndTime(); case TRIP_DURATION: - return new QuantityType<>(tripDetails.getDurationInMinutes(), MINUTE); + return tripDetails.getDurationInMinutes().map(value -> (State) new QuantityType<>(value, MINUTE)) + .orElse(UnDefType.UNDEF); case TRIP_START_ODOMETER: return new QuantityType<>((double) tripDetails.startOdometer / 1000, KILO(METRE)); case TRIP_STOP_ODOMETER: diff --git a/bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/handler/YamahaBridgeHandler.java b/bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/handler/YamahaBridgeHandler.java index 42725d7fe..74ad11e64 100644 --- a/bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/handler/YamahaBridgeHandler.java +++ b/bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/handler/YamahaBridgeHandler.java @@ -264,7 +264,8 @@ public class YamahaBridgeHandler extends BaseBridgeHandler onConnectivityError(e); return; } catch (ReceivedMessageParseException e) { - updateProperty(PROPERTY_MENU_ERROR, e.getMessage()); + String message = e.getMessage(); + updateProperty(PROPERTY_MENU_ERROR, message != null ? message : ""); // Some AVRs send unexpected responses. We log parser exceptions therefore. logger.debug("Parse error!", e); } finally { diff --git a/bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/handler/YamahaZoneThingHandler.java b/bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/handler/YamahaZoneThingHandler.java index 1da33f918..2ecbc45df 100644 --- a/bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/handler/YamahaZoneThingHandler.java +++ b/bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/handler/YamahaZoneThingHandler.java @@ -727,7 +727,8 @@ public class YamahaZoneThingHandler extends BaseThingHandler logger.debug("State update error. Changing thing to offline", e); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage()); } catch (ReceivedMessageParseException e) { - updateProperty(PROPERTY_LAST_PARSE_ERROR, e.getMessage()); + String message = e.getMessage(); + updateProperty(PROPERTY_LAST_PARSE_ERROR, message != null ? message : ""); // Some AVRs send unexpected responses. We log parser exceptions therefore. logger.debug("Parse error!", e); } diff --git a/bundles/org.openhab.binding.yeelight/src/main/java/org/openhab/binding/yeelight/internal/lib/services/DeviceManager.java b/bundles/org.openhab.binding.yeelight/src/main/java/org/openhab/binding/yeelight/internal/lib/services/DeviceManager.java index 9ea687d9d..648edd507 100644 --- a/bundles/org.openhab.binding.yeelight/src/main/java/org/openhab/binding/yeelight/internal/lib/services/DeviceManager.java +++ b/bundles/org.openhab.binding.yeelight/src/main/java/org/openhab/binding/yeelight/internal/lib/services/DeviceManager.java @@ -304,14 +304,26 @@ public class DeviceManager { device.setAddress(addressInfo[1].substring(2)); device.setPort(Integer.parseInt(addressInfo[2])); device.setOnline(true); - Color color = new Color(Integer.parseInt(bulbInfo.get("rgb"))); DeviceStatus status = device.getDeviceStatus(); - status.setR(color.getRed()); - status.setG(color.getGreen()); - status.setB(color.getBlue()); - status.setCt(Integer.parseInt(bulbInfo.get("ct"))); - status.setHue(Integer.parseInt(bulbInfo.get("hue"))); - status.setSat(Integer.parseInt(bulbInfo.get("sat"))); + String rgb = bulbInfo.get("rgb"); + if (rgb != null) { + Color color = new Color(Integer.parseInt(rgb)); + status.setR(color.getRed()); + status.setG(color.getGreen()); + status.setB(color.getBlue()); + } + String ct = bulbInfo.get("ct"); + if (ct != null) { + status.setCt(Integer.parseInt(ct)); + } + String hue = bulbInfo.get("hue"); + if (hue != null) { + status.setHue(Integer.parseInt(hue)); + } + String sat = bulbInfo.get("sat"); + if (sat != null) { + status.setSat(Integer.parseInt(sat)); + } } public static String getDefaultName(DeviceBase device) { diff --git a/bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/handler/ZWayDeviceHandler.java b/bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/handler/ZWayDeviceHandler.java index fc5a48c6e..8d6fed1d4 100644 --- a/bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/handler/ZWayDeviceHandler.java +++ b/bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/handler/ZWayDeviceHandler.java @@ -319,9 +319,9 @@ public abstract class ZWayDeviceHandler extends BaseThingHandler { // Channel thermostat mode if (channel.getUID().equals(new ChannelUID(getThing().getUID(), THERMOSTAT_MODE_CC_CHANNEL))) { // Load physical device - Integer nodeId = Integer.parseInt(channel.getProperties().get("nodeId")); - ZWaveDevice physicalDevice = zwayBridgeHandler.getZWayApi().getZWaveDevice(nodeId); - + String nodeIdString = channel.getProperties().get("nodeId"); + ZWaveDevice physicalDevice = nodeIdString == null ? null + : zwayBridgeHandler.getZWayApi().getZWaveDevice(Integer.parseInt(nodeIdString)); if (physicalDevice != null) { updateState(channel.getUID(), new DecimalType(physicalDevice.getInstances().get0() .getCommandClasses().get64().getData().getMode().getValue())); @@ -507,15 +507,15 @@ public abstract class ZWayDeviceHandler extends BaseThingHandler { } } else if (channel.getUID().equals(new ChannelUID(getThing().getUID(), THERMOSTAT_MODE_CC_CHANNEL))) { // Load physical device - Integer nodeId = Integer.parseInt(channel.getProperties().get("nodeId")); if (command instanceof DecimalType) { + String nodeIdString = channel.getProperties().get("nodeId"); logger.debug("Handle command: DecimalType"); - - zwayBridgeHandler.getZWayApi().getZWaveDeviceThermostatModeSet(nodeId, - Integer.parseInt(command.toString())); + if (nodeIdString != null) { + zwayBridgeHandler.getZWayApi().getZWaveDeviceThermostatModeSet(Integer.parseInt(nodeIdString), + Integer.parseInt(command.toString())); + } } else if (command instanceof RefreshType) { logger.debug("Handle command: RefreshType"); - refreshChannel(channel); } } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitChangeListener.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitChangeListener.java index 99fc4162c..c3a3aef27 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitChangeListener.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitChangeListener.java @@ -92,13 +92,21 @@ public class HomekitChangeListener implements ItemRegistryChangeListener { private void initialiseRevision() { int revision; try { - revision = Integer.parseInt(storage.get(REVISION_CONFIG)); + String revisionString = storage.get(REVISION_CONFIG); + if (revisionString == null) { + throw new NumberFormatException(); + } + revision = Integer.parseInt(revisionString); } catch (NumberFormatException e) { revision = 1; storage.put(REVISION_CONFIG, "" + revision); } try { - lastAccessoryCount = Integer.parseInt(storage.get(ACCESSORY_COUNT)); + String accessoryCountString = storage.get(ACCESSORY_COUNT); + if (accessoryCountString == null) { + throw new NumberFormatException(); + } + lastAccessoryCount = Integer.parseInt(accessoryCountString); } catch (NumberFormatException e) { lastAccessoryCount = 0; storage.put(ACCESSORY_COUNT, "" + accessoryRegistry.getAllAccessories().size()); diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAccessoryFactory.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAccessoryFactory.java index 69c13a0aa..5cde5abc6 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAccessoryFactory.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAccessoryFactory.java @@ -454,8 +454,6 @@ public class HomekitAccessoryFactory { * @return new characteristic type */ private static HomekitCharacteristicType legacyCheck(HomekitCharacteristicType characteristicType) { - if (LEGACY_CHARACTERISTICS_MAPPING.containsKey(characteristicType)) - return LEGACY_CHARACTERISTICS_MAPPING.get(characteristicType); - return characteristicType; + return LEGACY_CHARACTERISTICS_MAPPING.getOrDefault(characteristicType, characteristicType); } } diff --git a/bundles/org.openhab.io.hueemulation/src/main/java/org/openhab/io/hueemulation/internal/NetworkUtils.java b/bundles/org.openhab.io.hueemulation/src/main/java/org/openhab/io/hueemulation/internal/NetworkUtils.java index 032ce3516..c21b47620 100644 --- a/bundles/org.openhab.io.hueemulation/src/main/java/org/openhab/io/hueemulation/internal/NetworkUtils.java +++ b/bundles/org.openhab.io.hueemulation/src/main/java/org/openhab/io/hueemulation/internal/NetworkUtils.java @@ -25,6 +25,7 @@ import javax.ws.rs.core.Response.ResponseBuilder; import javax.ws.rs.core.UriInfo; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.io.hueemulation.internal.dto.response.HueResponse; import org.openhab.io.hueemulation.internal.dto.response.HueResponse.HueErrorMessage; import org.openhab.io.hueemulation.internal.dto.response.HueResponseSuccessSimple; @@ -91,8 +92,9 @@ public class NetworkUtils { * @param message A message * @return */ - public static Response singleError(Gson gson, UriInfo uri, int type, String message) { - HueResponse e = new HueResponse(new HueErrorMessage(type, uri.getPath().replace("/api", ""), message)); + public static Response singleError(Gson gson, UriInfo uri, int type, @Nullable String message) { + HueResponse e = new HueResponse( + new HueErrorMessage(type, uri.getPath().replace("/api", ""), message != null ? message : "")); String str = gson.toJson(Collections.singleton(e), new TypeToken>() { }.getType()); int httpCode = 500; diff --git a/bundles/org.openhab.io.hueemulation/src/main/java/org/openhab/io/hueemulation/internal/rest/Scenes.java b/bundles/org.openhab.io.hueemulation/src/main/java/org/openhab/io/hueemulation/internal/rest/Scenes.java index 16ae0d477..865c868bf 100644 --- a/bundles/org.openhab.io.hueemulation/src/main/java/org/openhab/io/hueemulation/internal/rest/Scenes.java +++ b/bundles/org.openhab.io.hueemulation/src/main/java/org/openhab/io/hueemulation/internal/rest/Scenes.java @@ -308,10 +308,11 @@ public class Scenes implements RegistryChangeListener { return NetworkUtils.singleError(cs.gson, uri, HueResponse.ARGUMENTS_INVALID, e.getMessage()); } + List lightsList = changeRequest.lights; return NetworkUtils.successList(cs.gson, Arrays.asList( // new HueSuccessGeneric(changeRequest.name, "/scenes/" + id + "/name"), // new HueSuccessGeneric(changeRequest.description, "/scenes/" + id + "/description"), // - new HueSuccessGeneric(changeRequest.lights != null ? String.join(",", changeRequest.lights) : null, + new HueSuccessGeneric(lightsList != null ? String.join(",", lightsList) : null, "/scenes/" + id + "/lights") // )); } diff --git a/bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/rest/mocks/DummyItemRegistry.java b/bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/rest/mocks/DummyItemRegistry.java index a5868fbf2..7317f27e1 100644 --- a/bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/rest/mocks/DummyItemRegistry.java +++ b/bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/rest/mocks/DummyItemRegistry.java @@ -23,6 +23,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.common.registry.RegistryChangeListener; import org.openhab.core.items.Item; +import org.openhab.core.items.ItemNotFoundException; import org.openhab.core.items.ItemRegistry; import org.openhab.core.items.RegistryHook; @@ -87,13 +88,21 @@ public class DummyItemRegistry implements ItemRegistry { } @Override - public Item getItem(String name) { - return items.get(name); + public Item getItem(String name) throws ItemNotFoundException { + Item item = items.get(name); + if (item == null) { + throw new ItemNotFoundException(name); + } + return item; } @Override - public Item getItemByPattern(String name) { - return items.get(name); + public Item getItemByPattern(String name) throws ItemNotFoundException { + Item item = items.get(name); + if (item == null) { + throw new ItemNotFoundException(name); + } + return item; } @Override diff --git a/bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/OpenHabToDeviceConverter.java b/bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/OpenHabToDeviceConverter.java index be26429f0..5d9738817 100644 --- a/bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/OpenHabToDeviceConverter.java +++ b/bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/OpenHabToDeviceConverter.java @@ -135,9 +135,9 @@ class OpenHabToDeviceConverter { final String manufacturer = StringUtils.isEmpty(properties.get("Manufacturer")) ? "openHAB" : properties.get("Manufacturer"); - final Integer standbyDelay = parseInteger(properties.get("Standby Command Delay")); - final Integer switchDelay = parseInteger(properties.get("Source Switch Delay")); - final Integer shutDownDelay = parseInteger(properties.get("Shutdown Delay")); + final Integer standbyDelay = parseInteger(properties.getOrDefault("Standby Command Delay", "0")); + final Integer switchDelay = parseInteger(properties.getOrDefault("Source Switch Delay", "0")); + final Integer shutDownDelay = parseInteger(properties.getOrDefault("Shutdown Delay", "0")); final NeeoDeviceTiming timing = new NeeoDeviceTiming(standbyDelay, switchDelay, shutDownDelay); diff --git a/bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/net/HttpRequest.java b/bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/net/HttpRequest.java index 030c6a8b0..bac60524f 100644 --- a/bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/net/HttpRequest.java +++ b/bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/net/HttpRequest.java @@ -74,7 +74,8 @@ public class HttpRequest implements AutoCloseable { content.close(); } } catch (IOException | IllegalStateException | ProcessingException e) { - return new HttpResponse(HttpStatus.SERVICE_UNAVAILABLE_503, e.getMessage()); + String message = e.getMessage(); + return new HttpResponse(HttpStatus.SERVICE_UNAVAILABLE_503, message != null ? message : ""); } } @@ -100,7 +101,8 @@ public class HttpRequest implements AutoCloseable { content.close(); } } catch (IOException | IllegalStateException | ProcessingException e) { - return new HttpResponse(HttpStatus.SERVICE_UNAVAILABLE_503, e.getMessage()); + String message = e.getMessage(); + return new HttpResponse(HttpStatus.SERVICE_UNAVAILABLE_503, message != null ? message : ""); } } diff --git a/bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/net/HttpResponse.java b/bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/net/HttpResponse.java index 8e47c2414..9535e7324 100644 --- a/bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/net/HttpResponse.java +++ b/bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/net/HttpResponse.java @@ -101,7 +101,7 @@ public class HttpResponse { return ""; } - return new String(contents, StandardCharsets.UTF_8); + return new String(localContents, StandardCharsets.UTF_8); } /** diff --git a/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/exception/ModbusConnectionException.java b/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/exception/ModbusConnectionException.java index ebd6c6ec0..c18669630 100644 --- a/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/exception/ModbusConnectionException.java +++ b/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/exception/ModbusConnectionException.java @@ -13,6 +13,7 @@ package org.openhab.io.transport.modbus.exception; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.io.transport.modbus.endpoint.ModbusSlaveEndpoint; /** @@ -45,7 +46,7 @@ public class ModbusConnectionException extends ModbusTransportException { } @Override - public String getMessage() { + public @Nullable String getMessage() { return String.format("Error connecting to endpoint %s", endpoint); } diff --git a/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/exception/ModbusUnexpectedResponseFunctionCodeException.java b/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/exception/ModbusUnexpectedResponseFunctionCodeException.java index 7f472f7a5..ff9e2f6fa 100644 --- a/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/exception/ModbusUnexpectedResponseFunctionCodeException.java +++ b/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/exception/ModbusUnexpectedResponseFunctionCodeException.java @@ -13,6 +13,7 @@ package org.openhab.io.transport.modbus.exception; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * Exception representing situation where function code of the response does not match request @@ -33,7 +34,7 @@ public class ModbusUnexpectedResponseFunctionCodeException extends ModbusTranspo } @Override - public String getMessage() { + public @Nullable String getMessage() { return String.format("Function code of request (%d) does not equal response (%d)", requestFunctionCode, responseFunctionCode); } diff --git a/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/exception/ModbusUnexpectedResponseSizeException.java b/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/exception/ModbusUnexpectedResponseSizeException.java index 16ba3adc5..76a8cef11 100644 --- a/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/exception/ModbusUnexpectedResponseSizeException.java +++ b/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/exception/ModbusUnexpectedResponseSizeException.java @@ -13,6 +13,7 @@ package org.openhab.io.transport.modbus.exception; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * Exception representing situation where data length of the response does not match request @@ -33,7 +34,7 @@ public class ModbusUnexpectedResponseSizeException extends ModbusTransportExcept } @Override - public String getMessage() { + public @Nullable String getMessage() { return String.format("Data length of the request (%d) does not equal response (%d). Slave response is invalid.", requestSize, responseSize); } diff --git a/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/exception/ModbusUnexpectedTransactionIdException.java b/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/exception/ModbusUnexpectedTransactionIdException.java index 312c9fdfd..36d8fc3c5 100644 --- a/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/exception/ModbusUnexpectedTransactionIdException.java +++ b/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/exception/ModbusUnexpectedTransactionIdException.java @@ -13,6 +13,7 @@ package org.openhab.io.transport.modbus.exception; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; /** * Exception representing situation where transaction id of the response does not match request @@ -33,7 +34,7 @@ public class ModbusUnexpectedTransactionIdException extends ModbusTransportExcep } @Override - public String getMessage() { + public @Nullable String getMessage() { return String.format("Transaction id of request (%d) does not equal response (%d). Slave response is invalid.", requestId, responseId); } diff --git a/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/internal/ModbusSlaveErrorResponseExceptionImpl.java b/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/internal/ModbusSlaveErrorResponseExceptionImpl.java index e8a11bde0..505f704c3 100644 --- a/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/internal/ModbusSlaveErrorResponseExceptionImpl.java +++ b/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/internal/ModbusSlaveErrorResponseExceptionImpl.java @@ -13,6 +13,7 @@ package org.openhab.io.transport.modbus.internal; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.io.transport.modbus.exception.ModbusSlaveErrorResponseException; import net.wimpi.modbus.ModbusSlaveException; @@ -43,7 +44,7 @@ public class ModbusSlaveErrorResponseExceptionImpl extends ModbusSlaveErrorRespo } @Override - public String getMessage() { + public @Nullable String getMessage() { return String.format("Slave responsed with error=%d", type); } diff --git a/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/internal/ModbusSlaveIOExceptionImpl.java b/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/internal/ModbusSlaveIOExceptionImpl.java index 27efbd7f4..24e8b0c09 100644 --- a/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/internal/ModbusSlaveIOExceptionImpl.java +++ b/bundles/org.openhab.io.transport.modbus/src/main/java/org/openhab/io/transport/modbus/internal/ModbusSlaveIOExceptionImpl.java @@ -15,6 +15,7 @@ package org.openhab.io.transport.modbus.internal; import java.io.IOException; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.io.transport.modbus.exception.ModbusSlaveIOException; import net.wimpi.modbus.ModbusIOException; @@ -40,7 +41,7 @@ public class ModbusSlaveIOExceptionImpl extends ModbusSlaveIOException { } @Override - public String getMessage() { + public @Nullable String getMessage() { return String.format("Modbus IO Error with cause=%s, EOF=%s, message='%s', cause2=%s", error.getClass().getSimpleName(), error instanceof ModbusIOException ? ((ModbusIOException) error).isEOF() : "?", error.getMessage(), diff --git a/bundles/org.openhab.persistence.dynamodb/src/main/java/org/openhab/persistence/dynamodb/internal/DynamoDBPersistenceService.java b/bundles/org.openhab.persistence.dynamodb/src/main/java/org/openhab/persistence/dynamodb/internal/DynamoDBPersistenceService.java index ca0f1f866..97ee8f0f4 100644 --- a/bundles/org.openhab.persistence.dynamodb/src/main/java/org/openhab/persistence/dynamodb/internal/DynamoDBPersistenceService.java +++ b/bundles/org.openhab.persistence.dynamodb/src/main/java/org/openhab/persistence/dynamodb/internal/DynamoDBPersistenceService.java @@ -422,7 +422,7 @@ public class DynamoDBPersistenceService extends AbstractBufferedPersistenceServi String tableName = tableNameResolver.fromItem(dynamoItem); Deque> batch = batchesByTable.computeIfAbsent(tableName, new Function<>() { @Override - public Deque> apply(String t) { + public Deque> apply(@Nullable String t) { return new ArrayDeque<>(); } }); diff --git a/bundles/org.openhab.persistence.dynamodb/src/test/java/org/openhab/persistence/dynamodb/internal/AbstractTwoItemIntegrationTest.java b/bundles/org.openhab.persistence.dynamodb/src/test/java/org/openhab/persistence/dynamodb/internal/AbstractTwoItemIntegrationTest.java index d409ea243..33e5212f6 100644 --- a/bundles/org.openhab.persistence.dynamodb/src/test/java/org/openhab/persistence/dynamodb/internal/AbstractTwoItemIntegrationTest.java +++ b/bundles/org.openhab.persistence.dynamodb/src/test/java/org/openhab/persistence/dynamodb/internal/AbstractTwoItemIntegrationTest.java @@ -15,6 +15,7 @@ package org.openhab.persistence.dynamodb.internal; import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assumptions.assumeTrue; +import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.Iterator; @@ -53,9 +54,9 @@ import org.openhab.core.types.State; @NonNullByDefault public abstract class AbstractTwoItemIntegrationTest extends BaseIntegrationTest { - protected static @Nullable ZonedDateTime beforeStore; - protected static @Nullable ZonedDateTime afterStore1; - protected static @Nullable ZonedDateTime afterStore2; + protected static ZonedDateTime beforeStore = ZonedDateTime.of(2100, 1, 1, 0, 0, 0, 0, ZoneId.systemDefault()); + protected static ZonedDateTime afterStore1 = ZonedDateTime.of(1900, 1, 1, 0, 0, 0, 0, ZoneId.systemDefault()); + protected static ZonedDateTime afterStore2 = ZonedDateTime.of(1900, 1, 1, 0, 0, 0, 0, ZoneId.systemDefault()); protected abstract String getItemName(); diff --git a/bundles/org.openhab.persistence.dynamodb/src/test/java/org/openhab/persistence/dynamodb/internal/BaseIntegrationTest.java b/bundles/org.openhab.persistence.dynamodb/src/test/java/org/openhab/persistence/dynamodb/internal/BaseIntegrationTest.java index 50bf179e8..8554f5769 100644 --- a/bundles/org.openhab.persistence.dynamodb/src/test/java/org/openhab/persistence/dynamodb/internal/BaseIntegrationTest.java +++ b/bundles/org.openhab.persistence.dynamodb/src/test/java/org/openhab/persistence/dynamodb/internal/BaseIntegrationTest.java @@ -175,16 +175,19 @@ public class BaseIntegrationTest { }); Map config = new HashMap<>(); - config.put("region", System.getProperty("DYNAMODBTEST_REGION")); - config.put("accessKey", System.getProperty("DYNAMODBTEST_ACCESS")); - config.put("secretKey", System.getProperty("DYNAMODBTEST_SECRET")); + String value = System.getProperty("DYNAMODBTEST_REGION"); + config.put("region", value != null ? value : ""); + value = System.getProperty("DYNAMODBTEST_ACCESS"); + config.put("accessKey", value != null ? value : ""); + value = System.getProperty("DYNAMODBTEST_SECRET"); + config.put("secretKey", value != null ? value : ""); config.put("tablePrefix", "dynamodb-integration-tests-"); // Disable buffering config.put("bufferSize", "0"); for (Entry entry : config.entrySet()) { - if (entry.getValue() == null) { + if (((String) entry.getValue()).isEmpty()) { LOGGER.warn(String.format( "Expecting %s to have value for integration tests. Integration tests will be skipped", entry.getKey())); diff --git a/bundles/org.openhab.transform.javascript/src/main/java/org/openhab/transform/javascript/internal/JavaScriptEngineManager.java b/bundles/org.openhab.transform.javascript/src/main/java/org/openhab/transform/javascript/internal/JavaScriptEngineManager.java index 5c31a461f..303e31719 100644 --- a/bundles/org.openhab.transform.javascript/src/main/java/org/openhab/transform/javascript/internal/JavaScriptEngineManager.java +++ b/bundles/org.openhab.transform.javascript/src/main/java/org/openhab/transform/javascript/internal/JavaScriptEngineManager.java @@ -57,9 +57,10 @@ public class JavaScriptEngineManager { */ protected CompiledScript getScript(final String filename) throws TransformationException { synchronized (compiledScriptMap) { - if (compiledScriptMap.containsKey(filename)) { + CompiledScript compiledScript = compiledScriptMap.get(filename); + if (compiledScript != null) { logger.debug("Loading JavaScript {} from cache.", filename); - return compiledScriptMap.get(filename); + return compiledScript; } else { final String path = TransformationScriptWatcher.TRANSFORM_FOLDER + File.separator + filename; logger.debug("Loading script {} from storage ", path); diff --git a/bundles/org.openhab.transform.map/src/test/java/org/openhab/transform/map/internal/MapTransformationServiceTest.java b/bundles/org.openhab.transform.map/src/test/java/org/openhab/transform/map/internal/MapTransformationServiceTest.java index 7189186b0..489f2062c 100644 --- a/bundles/org.openhab.transform.map/src/test/java/org/openhab/transform/map/internal/MapTransformationServiceTest.java +++ b/bundles/org.openhab.transform.map/src/test/java/org/openhab/transform/map/internal/MapTransformationServiceTest.java @@ -14,10 +14,7 @@ package org.openhab.transform.map.internal; import static org.junit.jupiter.api.Assertions.*; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; +import java.io.*; import java.util.Locale; import java.util.Properties; import java.util.concurrent.Callable; @@ -125,7 +122,10 @@ public class MapTransformationServiceTest { } }, 10000, 100); } catch (IOException e1) { - e1.printStackTrace(System.err); + PrintStream err = System.err; + if (err != null) { + e1.printStackTrace(err); + } } // Checks that an unknown input in an existing file give the expected diff --git a/bundles/pom.xml b/bundles/pom.xml index e39d79151..afb37fa9f 100644 --- a/bundles/pom.xml +++ b/bundles/pom.xml @@ -322,7 +322,17 @@ org.openhab.voice.voicerss + + target/dependency + + + + + org.lastnpe.eea + eea-all + 2.1.0 + org.openhab.core.bom @@ -367,10 +377,6 @@ - - - - @@ -475,7 +481,7 @@ runtime jar - javax.activation,org.apache.karaf.features + javax.activation,org.apache.karaf.features,org.lastnpe.eea ${dep.noembedding} ${project.build.directory}/classes true @@ -484,6 +490,22 @@ jar + + unpack-eea + + unpack + + + + + org.lastnpe.eea + eea-all + 2.1.0 + true + + + + diff --git a/itests/org.openhab.binding.modbus.tests/src/main/java/org/openhab/binding/modbus/tests/AbstractModbusOSGiTest.java b/itests/org.openhab.binding.modbus.tests/src/main/java/org/openhab/binding/modbus/tests/AbstractModbusOSGiTest.java index 1c457a3b0..efbc79ad6 100644 --- a/itests/org.openhab.binding.modbus.tests/src/main/java/org/openhab/binding/modbus/tests/AbstractModbusOSGiTest.java +++ b/itests/org.openhab.binding.modbus.tests/src/main/java/org/openhab/binding/modbus/tests/AbstractModbusOSGiTest.java @@ -211,7 +211,7 @@ public abstract class AbstractModbusOSGiTest extends JavaOSGiTest { addedLinks.add(link); } - protected List getStateUpdates(String itemName) { + protected @Nullable List getStateUpdates(String itemName) { return stateSubscriber.stateUpdates.get(itemName); } diff --git a/itests/pom.xml b/itests/pom.xml index a051f8134..5930e170f 100644 --- a/itests/pom.xml +++ b/itests/pom.xml @@ -35,6 +35,10 @@ org.openhab.persistence.mapdb.tests + + target/dependency + + org.openhab.core.bom @@ -72,6 +76,29 @@ biz.aQute.bnd bnd-maven-plugin + + org.apache.maven.plugins + maven-dependency-plugin + 3.1.1 + + + unpack-eea + + unpack + + + + + org.lastnpe.eea + eea-all + 2.1.0 + true + + + + + + diff --git a/pom.xml b/pom.xml index 1e47ed4d0..6cdc99711 100644 --- a/pom.xml +++ b/pom.xml @@ -284,6 +284,10 @@ Import-Package: \\ 3.8.1 eclipse + + CLASSPATH + ${project.build.directory}/dependency + -err:+nullAnnot(org.eclipse.jdt.annotation.Nullable|org.eclipse.jdt.annotation.NonNull|org.eclipse.jdt.annotation.NonNullByDefault),+inheritNullAnnot,-nullUncheckedConversion -warn:+null,+inheritNullAnnot,+nullAnnotConflict,-nullUncheckedConversion,+nullAnnotRedundant,+nullDereference