Fix sonars in apex-pdp
[policy/apex-pdp.git] / context / context-management / src / main / java / org / onap / policy / apex / context / impl / distribution / AbstractDistributor.java
index 49b0a66..3444f93 100644 (file)
@@ -1,6 +1,8 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ *  Modifications Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,7 +26,6 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
-
 import org.onap.policy.apex.context.ContextAlbum;
 import org.onap.policy.apex.context.ContextException;
 import org.onap.policy.apex.context.Distributor;
@@ -74,7 +75,7 @@ public abstract class AbstractDistributor implements Distributor {
     /**
      * Create an instance of an abstract Context Distributor.
      */
-    public AbstractDistributor() {
+    protected AbstractDistributor() {
         LOGGER.entry("AbstractContextDistributor()");
         LOGGER.exit("AbstractContextDistributor()");
     }
@@ -210,16 +211,12 @@ public abstract class AbstractDistributor implements Distributor {
      * {@inheritDoc}.
      */
     @Override
-    public void removeContextAlbum(final AxContextAlbum contextAlbum) throws ContextException {
+    public void removeContextAlbum(final AxArtifactKey axContextAlbumKey) throws ContextException {
         synchronized (albumMaps) {
-            // Check if the map already exists, if not return
-            if (!albumMaps.containsKey(contextAlbum.getKey())) {
-                LOGGER.warn("map remove failed, supplied map is null");
+            // Remove the map from the distributor
+            if (null == albumMaps.remove(axContextAlbumKey)) {
                 throw new ContextException("map update failed, supplied map is null");
             }
-
-            // Remove the map from the distributor
-            albumMaps.remove(contextAlbum.getKey());
         }
     }