Added nullness annotations to fix NPE in HttpServiceUtil (#2234)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp 2021-03-12 22:12:03 +01:00 committed by GitHub
parent e20348e8d6
commit 26e9a8ed9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {