summaryrefslogtreecommitdiffstats
path: root/utils/src/main/java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-04-06 11:26:13 -0400
committerJim Hahn <jrh3@att.com>2020-04-06 11:41:32 -0400
commit82ac8775dfa540fa856ecfd284c69afa44790dd8 (patch)
tree551db3b365be7a0a13aabaa1c52191079d305369 /utils/src/main/java
parenta56d3929f2387252525577fb36f9e03933064b8f (diff)
More sonar issues in common
Fixed additional sonar issues: - infinit loop; while the issue is bogus, it was easy enough to modify the code to satisfy sonar - doesn't like "volatile"; again, the issue is bogus, but easy enough to modify the code Disabled a couple of sonars in NetworkUtil, as they are not actually an issue. Issue-ID: POLICY-2305 Change-Id: I5500183e3fe4060696994cff55bdae4ba7e138c7 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'utils/src/main/java')
-rw-r--r--utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java12
1 files changed, 10 insertions, 2 deletions
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 14362627..9a3d455b 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
@@ -105,7 +105,11 @@ public class NetworkUtil {
* @throws IOException if a socket cannot be created
*/
public static int allocPort(InetSocketAddress hostAddr) throws IOException {
- try (ServerSocket socket = new ServerSocket()) {
+ /*
+ * The socket is only used to find an unused address for a new server. As a
+ * result, it poses no security risk, thus the sonar issue can be ignored.
+ */
+ try (ServerSocket socket = new ServerSocket()) { // NOSONAR
socket.bind(hostAddr);
return socket.getLocalPort();
@@ -134,7 +138,11 @@ public class NetworkUtil {
throws InterruptedException {
int retry = 0;
while (retry < retries) {
- try (Socket s = new Socket(host, port)) {
+ /*
+ * As with the server socket, this is only used to see if the port is open,
+ * thus the sonar issue can be ignored.
+ */
+ try (Socket s = new Socket(host, port)) { // NOSONAR
logger.debug("{}:{} connected - retries={} interval={}", host, port, retries, interval);
return true;
} catch (final IOException e) {