Remove code smell and bug 19/2819/1
authorelinuxhenrik <henrik.b.andersson@est.tech>
Tue, 17 Mar 2020 09:21:39 +0000 (10:21 +0100)
committerelinuxhenrik <henrik.b.andersson@est.tech>
Tue, 17 Mar 2020 09:21:45 +0000 (10:21 +0100)
Change-Id: I77e57ed585d5d9425d8fe8e4589a25cf7b61adf3
Issue-ID: NONRTRIC-142
Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
policy-agent/src/main/java/org/oransc/policyagent/repository/Lock.java
policy-agent/src/main/java/org/oransc/policyagent/tasks/RicSynchronizationTask.java
policy-agent/src/test/java/org/oransc/policyagent/repository/LockTest.java

index ff3f331..70d00cb 100644 (file)
@@ -168,7 +168,7 @@ public class Lock {
         lockRequestQueue.add(new LockRequest(callback, lockType, this));
     }
 
-    @SuppressWarnings("java:S2274")
+    @SuppressWarnings("java:S2274") // Always invoke wait() and await() methods inside a loop
     private synchronized void waitForUnlock() {
         try {
             this.wait();
index 0a0ab82..79b92e4 100644 (file)
@@ -64,6 +64,7 @@ public class RicSynchronizationTask {
     private final Policies policies;
     private final Services services;
 
+    @SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally.
     public RicSynchronizationTask(A1ClientFactory a1ClientFactory, PolicyTypes policyTypes, Policies policies,
         Services services) {
         this.a1ClientFactory = a1ClientFactory;
@@ -72,7 +73,7 @@ public class RicSynchronizationTask {
         this.services = services;
     }
 
-    @SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally
+    @SuppressWarnings("squid:S2445") // Blocks should be synchronized on "private final" fields
     public void run(Ric ric) {
         logger.debug("Handling ric: {}", ric.getConfig().name());
 
@@ -101,7 +102,6 @@ public class RicSynchronizationTask {
         return Flux.concat(recoverTypes, policiesDeletedInRic, policiesRecreatedInRic);
     }
 
-    @SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally
     private void onSynchronizationComplete(Ric ric) {
         logger.info("Synchronization completed for: {}", ric.name());
         ric.setState(RicState.IDLE);
@@ -124,7 +124,6 @@ public class RicSynchronizationTask {
         }
     }
 
-    @SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally
     private void onSynchronizationError(Ric ric, Throwable t) {
         logger.warn("Synchronization failed for ric: {}, reason: {}", ric.name(), t.getMessage());
         // If synchronization fails, try to remove all instances
@@ -142,7 +141,6 @@ public class RicSynchronizationTask {
                 () -> onSynchronizationComplete(ric));
     }
 
-    @SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally
     private void onRecoveryError(Ric ric, Throwable t) {
         logger.warn("Synchronization failure recovery failed for ric: {}, reason: {}", ric.name(), t.getMessage());
         ric.setState(RicState.UNDEFINED);
index 6fd6c8b..814056b 100644 (file)
@@ -36,6 +36,7 @@ import reactor.test.StepVerifier;
 @ExtendWith(MockitoExtension.class)
 public class LockTest {
 
+    @SuppressWarnings("squid:S2276") // Remove this use of "Thread.sleep()".
     private void sleep() {
         try {
             Thread.sleep(100);