From 3fd9dc0e5c584702d25982172bb5ee44b6b57aa3 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Thu, 12 Apr 2018 14:23:25 -0400 Subject: Sonar fixes for policy-core locks Made a number of changes to the locking code in policy-core, to address sonar issues. This entaileed changing some of the Lock API methods to return OperResult instead of Boolean. Updated distributed locking with the new API return types. Simplified Thread creation using functional methods. Change-Id: If32bf7a435d2aedb969de1b77c7e7e27e110ecb0 Issue-ID: POLICY-728 Signed-off-by: Jim Hahn --- .../distributed/locking/DistributedLockingFeature.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'feature-distributed-locking/src/main/java') diff --git a/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java b/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java index 7906dba7..5994beb6 100644 --- a/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java +++ b/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java @@ -86,24 +86,24 @@ public class DistributedLockingFeature implements PolicyEngineFeatureAPI, Policy } @Override - public Boolean beforeUnlock(String resourceId, String owner) { + public OperResult beforeUnlock(String resourceId, String owner) { TargetLock tLock = new TargetLock(resourceId, uuid, owner, lockProps); - return tLock.unlock(); + return(tLock.unlock() ? OperResult.OPER_ACCEPTED : OperResult.OPER_DENIED); } @Override - public Boolean beforeIsLockedBy(String resourceId, String owner) { + public OperResult beforeIsLockedBy(String resourceId, String owner) { TargetLock tLock = new TargetLock(resourceId, uuid, owner, lockProps); - - return tLock.isActive(); + + return(tLock.isActive() ? OperResult.OPER_ACCEPTED : OperResult.OPER_DENIED); } @Override - public Boolean beforeIsLocked(String resourceId) { + public OperResult beforeIsLocked(String resourceId) { TargetLock tLock = new TargetLock(resourceId, uuid, "dummyOwner", lockProps); - - return tLock.isLocked(); + + return(tLock.isLocked() ? OperResult.OPER_ACCEPTED : OperResult.OPER_DENIED); } @Override -- cgit 1.2.3-korg