diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/net/HttpServiceUtil.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/net/HttpServiceUtil.java index 894baa3b5..6e1b37369 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/net/HttpServiceUtil.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/net/HttpServiceUtil.java @@ -12,6 +12,7 @@ */ package org.openhab.core.net; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.framework.InvalidSyntaxException; @@ -24,6 +25,7 @@ import org.slf4j.LoggerFactory; * * @author Markus Rathgeb - Initial contribution */ +@NonNullByDefault public class HttpServiceUtil { private HttpServiceUtil() { @@ -45,9 +47,6 @@ public class HttpServiceUtil { // Utility method that could be used for non-secure and secure port. private static int getHttpServicePortProperty(final BundleContext bc, final String propertyName) { - Object value; - int port = -1; - // Try to find the port by using the service property (respect service ranking). final ServiceReference[] refs; try { @@ -59,6 +58,9 @@ public class HttpServiceUtil { return -1; } + Object value; + int port = -1; + if (refs != null) { int candidate = Integer.MIN_VALUE; for (final ServiceReference ref : refs) {