From 82ac8775dfa540fa856ecfd284c69afa44790dd8 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 6 Apr 2020 11:26:13 -0400 Subject: 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 --- .../endpoints/http/server/internal/JettyServletServer.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'policy-endpoints/src/main/java/org/onap') diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java index f7f2fc15..6825f07c 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java @@ -115,7 +115,7 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable /** * Jetty thread. */ - protected volatile Thread jettyThread; + protected Thread jettyThread; /** * Start condition. @@ -418,12 +418,13 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable this.stop(); - if (this.jettyThread == null) { - return; + Thread jettyThreadCopy; + synchronized (this) { + if ((jettyThreadCopy = this.jettyThread) == null) { + return; + } } - Thread jettyThreadCopy = this.jettyThread; - if (jettyThreadCopy.isAlive()) { try { jettyThreadCopy.join(2000L); -- cgit 1.2.3-korg