Fix nullable issue (#18109)

Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
Kai Kreuzer 2025-01-15 16:45:23 +01:00 committed by GitHub
parent 7870b15fc3
commit 968cc56452
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,6 +12,8 @@
*/ */
package org.openhab.binding.nuki.internal; package org.openhab.binding.nuki.internal;
import java.util.UUID;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
@ -106,7 +108,7 @@ public class NukiHandlerFactory extends BaseThingHandlerFactory {
} }
} }
private @Nullable String createCallbackUrl(String id) { private @Nullable String createCallbackUrl(@Nullable String id) {
final String ipAddress = networkAddressService.getPrimaryIpv4HostAddress(); final String ipAddress = networkAddressService.getPrimaryIpv4HostAddress();
if (ipAddress == null) { if (ipAddress == null) {
logger.warn("No network interface could be found to get callback address"); logger.warn("No network interface could be found to get callback address");
@ -118,7 +120,8 @@ public class NukiHandlerFactory extends BaseThingHandlerFactory {
logger.warn("Cannot find port of the http service."); logger.warn("Cannot find port of the http service.");
return null; return null;
} }
String callbackUrl = NukiLinkBuilder.callbackUri(ipAddress, port, id).toString(); String callbackUrl = NukiLinkBuilder
.callbackUri(ipAddress, port, id != null ? id : UUID.randomUUID().toString()).toString();
logger.trace("callbackUrl[{}]", callbackUrl); logger.trace("callbackUrl[{}]", callbackUrl);
return callbackUrl; return callbackUrl;
} }