From 7ac967b67aca79163b7e7242d32931c59d87d502 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 5 Jul 2019 10:04:55 -0400 Subject: Fix sonar issue in common/utils Renamed a constant. Change-Id: I5e1f2fb6de8445a8f667ea48a595773173c6beae Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn --- .../common/endpoints/http/server/internal/JettyJerseyServer.java | 3 ++- .../main/java/org/onap/policy/common/utils/network/NetworkUtil.java | 2 +- .../java/org/onap/policy/common/utils/network/NetworkUtilTest.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java index 0aaf1ccb..78661a45 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java @@ -22,6 +22,7 @@ package org.onap.policy.common.endpoints.http.server.internal; import io.swagger.jersey.config.JerseyJaxrsConfig; import java.util.HashMap; +import org.apache.commons.lang3.StringUtils; import org.eclipse.jetty.servlet.ServletHolder; import org.glassfish.jersey.server.ServerProperties; import org.onap.policy.common.utils.network.NetworkUtil; @@ -119,7 +120,7 @@ public class JettyJerseyServer extends JettyServletServer { ServletHolder swaggerServlet = context.addServlet(JerseyJaxrsConfig.class, "/"); String hostname = this.connector.getHost(); - if (hostname == null || hostname.isEmpty() || hostname.equals(NetworkUtil.IPv4_WILDCARD_ADDRESS)) { + if (StringUtils.isBlank(hostname) || hostname.equals(NetworkUtil.IPV4_WILDCARD_ADDRESS)) { hostname = NetworkUtil.getHostname(); } diff --git a/utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java b/utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java index 6014b581..14362627 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java +++ b/utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java @@ -42,7 +42,7 @@ public class NetworkUtil { /** * IPv4 Wildcard IP address. */ - public static final String IPv4_WILDCARD_ADDRESS = "0.0.0.0"; + public static final String IPV4_WILDCARD_ADDRESS = "0.0.0.0"; /** diff --git a/utils/src/test/java/org/onap/policy/common/utils/network/NetworkUtilTest.java b/utils/src/test/java/org/onap/policy/common/utils/network/NetworkUtilTest.java index c29da2c7..a0b8353d 100644 --- a/utils/src/test/java/org/onap/policy/common/utils/network/NetworkUtilTest.java +++ b/utils/src/test/java/org/onap/policy/common/utils/network/NetworkUtilTest.java @@ -42,7 +42,7 @@ public class NetworkUtilTest { @Test public void test() throws InterruptedException, IOException { - assertNotNull(NetworkUtil.IPv4_WILDCARD_ADDRESS); + assertNotNull(NetworkUtil.IPV4_WILDCARD_ADDRESS); assertFalse(NetworkUtil.isTcpPortOpen(LOCALHOST, NetworkUtil.allocPort(), 1, 5)); assertNotNull(NetworkUtil.getHostname()); assertNotNull(NetworkUtil.getHostIp()); -- cgit 1.2.3-korg