From e0c537f4463b6664e108e12962e1f4b34544776c Mon Sep 17 00:00:00 2001 From: sourabh_sourabh Date: Wed, 23 Oct 2024 15:12:41 +0100 Subject: Refactor: Improve code quality and compliance with SonarQube standards - Consolidated multiple `if` statements to enhance readability and maintainability. - Replaced traditional `instanceof` checks followed by casting with the new pattern matching syntax for improved type safety and clarity. - Removed unnecessary casts and streamlined code in `addYangLeafList` and `addDataNodeFromNormalizedNode` methods. Issue-ID: CPS-1957 Change-Id: I46696dc184b6b3c3d0fe3a6bd12267a4e0d76193 Signed-off-by: sourabh_sourabh --- .../cps/ncmp/impl/inventory/sync/ModuleSyncWatchdog.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'cps-ncmp-service/src') diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncWatchdog.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncWatchdog.java index 4061298cd0..6b3452734e 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncWatchdog.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncWatchdog.java @@ -92,16 +92,14 @@ public class ModuleSyncWatchdog { } private void populateWorkQueueIfNeeded() { - if (moduleSyncWorkQueue.isEmpty()) { - if (workQueueLock.tryLock()) { - try { - populateWorkQueue(); - if (moduleSyncWorkQueue.isEmpty()) { - setPreviouslyLockedCmHandlesToAdvised(); - } - } finally { - workQueueLock.unlock(); + if (moduleSyncWorkQueue.isEmpty() && workQueueLock.tryLock()) { + try { + populateWorkQueue(); + if (moduleSyncWorkQueue.isEmpty()) { + setPreviouslyLockedCmHandlesToAdvised(); } + } finally { + workQueueLock.unlock(); } } } -- cgit 1.2.3-korg