[unifi] Fix NullPointerException (#17421)

* Fix NPE
* Null warning

Signed-off-by: Leo Siepel <leosiepel@gmail.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
lsiepel 2024-09-16 13:32:10 +02:00 committed by Ciprian Pascu
parent ed1236c00f
commit 37d732d76c

View File

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