Remove check before removing from hazelcast cache 29/139729/1
authoremaclee <lee.anjella.macabuhay@est.tech>
Thu, 19 Dec 2024 12:25:56 +0000 (12:25 +0000)
committeremaclee <lee.anjella.macabuhay@est.tech>
Thu, 19 Dec 2024 12:38:30 +0000 (12:38 +0000)
Issue-ID: CPS-2420
Change-Id: I2299d5790792f7c2b2b1a6aa371b5ea43c6a9ee8
Signed-off-by: emaclee <lee.anjella.macabuhay@est.tech>
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationService.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncTasks.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManager.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncTasksSpec.groovy

index fed8cc7..ed5e703 100644 (file)
@@ -319,10 +319,8 @@ public class CmHandleRegistrationService {
 
     // CPS-1239 Robustness cleaning of in progress cache
     private void removeDeletedCmHandleFromModuleSyncMap(final String cmHandleId) {
-        if (moduleSyncStartedOnCmHandles.containsKey(cmHandleId)) {
-            moduleSyncStartedOnCmHandles.removeAsync(cmHandleId);
-            log.debug("{} will be removed asynchronously from in progress map", cmHandleId);
-        }
+        moduleSyncStartedOnCmHandles.removeAsync(cmHandleId);
+        log.debug("{} will be removed asynchronously from in progress map", cmHandleId);
     }
 
     private List<CmHandleRegistrationResponse> upgradeCmHandles(final Map<YangModelCmHandle, CmHandleState>
index fd8a994..9450805 100644 (file)
@@ -125,10 +125,8 @@ public class ModuleSyncTasks {
     }
 
     private void removeResetCmHandleFromModuleSyncMap(final String resetCmHandleId) {
-        if (moduleSyncStartedOnCmHandles.containsKey(resetCmHandleId)) {
-            moduleSyncStartedOnCmHandles.removeAsync(resetCmHandleId);
-            log.info("{} will be removed asynchronously from in progress map", resetCmHandleId);
-        }
+        moduleSyncStartedOnCmHandles.removeAsync(resetCmHandleId);
+        log.info("{} will be removed asynchronously from in progress map", resetCmHandleId);
     }
 
     private static boolean isCmHandleInAdvisedState(final YangModelCmHandle yangModelCmHandle) {
index 6e89662..f68bb3b 100644 (file)
@@ -172,10 +172,7 @@ public class TrustLevelManager {
      * @param cmHandleIds       cm handle ids to be removed from the cache
      */
     public void removeCmHandles(final Collection<String> cmHandleIds) {
-        final Set<String> cmHandlesToRemove = trustLevelPerCmHandleId.keySet().stream()
-                .filter(cmHandleIds::contains)
-                .collect(Collectors.toSet());
-        for (final String cmHandleId : cmHandlesToRemove) {
+        for (final String cmHandleId : cmHandleIds) {
             trustLevelPerCmHandleId.removeAsync(cmHandleId);
         }
     }
index 02d50c2..c7fe45d 100644 (file)
@@ -214,18 +214,6 @@ class ModuleSyncTasksSpec extends Specification {
             'module upgrade failed' | MODULE_UPGRADE_FAILED
     }
 
-
-    def 'Remove non-existing cm handle id from hazelcast map'() {
-        given: 'hazelcast map does not contains cm handle id'
-            def result = moduleSyncStartedOnCmHandles.get('non-existing-cm-handle')
-            assert result == null
-        when: 'remove cm handle entry from  hazelcast map'
-            objectUnderTest.removeResetCmHandleFromModuleSyncMap('non-existing-cm-handle')
-        then: 'no event is logged'
-            def loggingEvent = getLoggingEvent()
-            assert loggingEvent == null
-    }
-
     def cmHandleByIdAndState(cmHandleId, cmHandleState) {
         return new YangModelCmHandle(id: cmHandleId, compositeState: new CompositeState(cmHandleState: cmHandleState))
     }