[unifi] Fix NullPointerException (#17421)

* Fix NPE
* Null warning

Signed-off-by: Leo Siepel <leosiepel@gmail.com>
This commit is contained in:
lsiepel 2024-09-16 13:32:10 +02:00 committed by Leo Siepel
parent 600ca69c94
commit 2f6db504c9

View File

@ -89,7 +89,8 @@ public class UniFiPoePortThingHandler extends UniFiBaseThingHandler<UniFiSwitchP
} else { } else {
final String channelConfigPoeEnableMode = (String) channel.getConfiguration() final String channelConfigPoeEnableMode = (String) channel.getConfiguration()
.get(CHANNEL_ENABLE_PARAMETER_MODE); .get(CHANNEL_ENABLE_PARAMETER_MODE);
poeEnableMode = channelConfigPoeEnableMode.isBlank() ? CHANNEL_ENABLE_PARAMETER_MODE_AUTO poeEnableMode = channelConfigPoeEnableMode == null || channelConfigPoeEnableMode.isBlank()
? CHANNEL_ENABLE_PARAMETER_MODE_AUTO
: channelConfigPoeEnableMode; : channelConfigPoeEnableMode;
return true; return true;
} }
@ -139,7 +140,7 @@ public class UniFiPoePortThingHandler extends UniFiBaseThingHandler<UniFiSwitchP
return state; return state;
} }
private <Q extends Quantity<Q>> State safeDouble(final String value, final Unit<Q> unit) { private <Q extends Quantity<Q>> State safeDouble(@Nullable final String value, final Unit<Q> unit) {
try { try {
return value == null ? UnDefType.UNDEF : QuantityType.valueOf(Double.parseDouble(value), unit); return value == null ? UnDefType.UNDEF : QuantityType.valueOf(Double.parseDouble(value), unit);
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {