From 18c81f810f26f57196c0a2ebcbd911a2f822c1db Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 8 Apr 2020 10:46:40 -0400 Subject: Address more sonar issues in drools-pdp Addressed the following sonar issues: - use of "synchronized" - use Files.delete() instead of File.delete() Issue-ID: POLICY-2305 Change-Id: Id55628fe12d9d764616e57321382a70cb5704ba1 Signed-off-by: Jim Hahn --- .../java/org/onap/policy/drools/core/lock/LockImpl.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'policy-core/src') diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/lock/LockImpl.java b/policy-core/src/main/java/org/onap/policy/drools/core/lock/LockImpl.java index 9596dbe8..8866eb82 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/core/lock/LockImpl.java +++ b/policy-core/src/main/java/org/onap/policy/drools/core/lock/LockImpl.java @@ -100,13 +100,15 @@ public class LockImpl implements Lock, Serializable { * This method always succeeds, unless the lock is already unavailable. */ @Override - public synchronized boolean free() { - if (isUnavailable()) { - return false; - } + public boolean free() { + synchronized (this) { + if (isUnavailable()) { + return false; + } - logger.info("releasing lock: {}", this); - setState(LockState.UNAVAILABLE); + logger.info("releasing lock: {}", this); + setState(LockState.UNAVAILABLE); + } return true; } -- cgit 1.2.3-korg