Sonar cleanup 95/42795/2
authorMagnusen, Drew (dm741q) <dm741q@att.com>
Fri, 13 Apr 2018 18:53:49 +0000 (13:53 -0500)
committerJorge Hernandez <jh1730@att.com>
Sat, 14 Apr 2018 00:01:17 +0000 (00:01 +0000)
Sonar cleanup for distributed-locking

Issue-ID: POLICY-728
Change-Id: I52523a0149436805509706a4a732d1da8a1b4511
Signed-off-by: Magnusen, Drew (dm741q) <dm741q@att.com>
feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java
policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureAPI.java
policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockManager.java
policy-core/src/main/java/org/onap/policy/drools/core/lock/SimpleLockManager.java

index 5994beb..019452a 100644 (file)
@@ -119,7 +119,7 @@ public class DistributedLockingFeature implements PolicyEngineFeatureAPI, Policy
                long heartbeatInterval = this.lockProps.getHeartBeatIntervalProperty();
                
                cleanLockTable();
-               heartbeat = new Heartbeat(uuid, lockProps);
+               initHeartbeat(lockProps);
                
                this.scheduledExecutorService = Executors.newScheduledThreadPool(1);
                this.scheduledExecutorService.scheduleAtFixedRate(heartbeat, heartbeatInterval, heartbeatInterval, TimeUnit.MILLISECONDS);
@@ -158,6 +158,14 @@ public class DistributedLockingFeature implements PolicyEngineFeatureAPI, Policy
                
        }
 
+       /**
+        * Initialize the static heartbeat object
+        */
+       private static void initHeartbeat(DistributedLockingProperties lockProps) {
+               heartbeat = new Heartbeat(uuid, lockProps);
+               
+       }
+       
        public static Heartbeat getHeartbeat() {
                return heartbeat;
        }
index 9f42936..d4e7bee 100644 (file)
@@ -64,7 +64,7 @@ public interface PolicyResourceLockFeatureAPI extends OrderedService {
     /**
      * Result of a requested operation.
      */
-    public static enum OperResult {
+    public enum OperResult {
 
         /**
          * The implementer accepted the request; no additional locking logic should be
index a9305e5..97e7242 100644 (file)
@@ -130,11 +130,11 @@ public class PolicyResourceLockManager extends SimpleLockManager {
         }
 
 
-        return doBoolIntercept(impl -> impl.beforeIsLocked(resourceId), () -> {
+        return doBoolIntercept(impl -> impl.beforeIsLocked(resourceId), () -> 
 
             // implementer didn't do the work - defer to the superclass
-            return super.isLocked(resourceId);
-        });
+           super.isLocked(resourceId)
+        );
     }
 
     /**
@@ -151,11 +151,11 @@ public class PolicyResourceLockManager extends SimpleLockManager {
             throw makeNullArgException(MSG_NULL_OWNER);
         }
 
-        return doBoolIntercept(impl -> impl.beforeIsLockedBy(resourceId, owner), () -> {
+        return doBoolIntercept(impl -> impl.beforeIsLockedBy(resourceId, owner), () -> 
 
             // implementer didn't do the work - defer to the superclass
-            return super.isLockedBy(resourceId, owner);
-        });
+            super.isLockedBy(resourceId, owner)
+        );
     }
 
     /**
@@ -210,6 +210,8 @@ public class PolicyResourceLockManager extends SimpleLockManager {
      */
     private static class Singleton {
 
+        private static final PolicyResourceLockManager instance = new PolicyResourceLockManager();
+        
         /**
          * Not invoked.
          */
@@ -217,7 +219,6 @@ public class PolicyResourceLockManager extends SimpleLockManager {
             super();
         }
 
-        private static final PolicyResourceLockManager instance = new PolicyResourceLockManager();
     }
 
     /**
index 14cffaa..c2d58b8 100644 (file)
@@ -49,9 +49,6 @@ public class SimpleLockManager {
         super();
     }
 
-    // TODO: for ease of use by clients, should we always invoke the callback, even though
-    // this is synchronous?
-
     /**
      * Attempts to lock a resource. This method ignores the callback and always returns a
      * {@link CompletedLockRequest}.