diff options
author | sourabh_sourabh <sourabh.sourabh@est.tech> | 2024-10-23 15:12:41 +0100 |
---|---|---|
committer | Sourabh Sourabh <sourabh.sourabh@est.tech> | 2024-10-24 10:27:41 +0000 |
commit | e0c537f4463b6664e108e12962e1f4b34544776c (patch) | |
tree | 30477a8d6b505ee1731d8657e8a76650ff1d285c /cps-ncmp-service/src | |
parent | d612628bae7c468ef69dc04a1fed89d3ba4b8f34 (diff) |
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 <sourabh.sourabh@est.tech>
Diffstat (limited to 'cps-ncmp-service/src')
-rw-r--r-- | cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncWatchdog.java | 16 |
1 files changed, 7 insertions, 9 deletions
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(); } } } |