Use plain HashMap instead of IdentityHashMap 11/108711/3
authorJim Hahn <jrh3@att.com>
Tue, 2 Jun 2020 21:17:20 +0000 (17:17 -0400)
committerJim Hahn <jrh3@att.com>
Tue, 2 Jun 2020 21:21:43 +0000 (17:21 -0400)
The javadocs say not to use IdentityHashMap except in special cases.
Modified the Actor code to use HashMap instead.

Issue-ID: POLICY-2604
Change-Id: Idcae4fe2e1e600fbb01cdcd09b1caddf2820740a
Signed-off-by: Jim Hahn <jrh3@att.com>
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/FutureManager.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/ListenerManager.java

index aac2f77..42aaa82 100644 (file)
@@ -20,7 +20,8 @@
 
 package org.onap.policy.controlloop.actorserviceprovider.pipeline;
 
-import java.util.IdentityHashMap;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.concurrent.Future;
 import lombok.NoArgsConstructor;
 
@@ -38,8 +39,7 @@ public class FutureManager extends ListenerManager {
      * needed if {@link #remove(Future)} is invoked, so that the same {@link Runnable} is
      * used each time.
      */
-    @SuppressWarnings("rawtypes")
-    private final IdentityHashMap<Future, Runnable> future2listener = new IdentityHashMap<>(5);
+    private final Map<Future<?>, Runnable> future2listener = new HashMap<>(5);
 
     /**
      * Adds a future that is to be canceled when this controller is stopped. Note: if the
index 1d64a87..b810de3 100644 (file)
@@ -21,7 +21,8 @@
 package org.onap.policy.controlloop.actorserviceprovider.pipeline;
 
 import java.util.ArrayList;
-import java.util.IdentityHashMap;
+import java.util.HashMap;
+import java.util.Map;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
 import org.onap.policy.controlloop.actorserviceprovider.Util;
@@ -40,7 +41,7 @@ public class ListenerManager {
     /**
      * Listeners to be executed when {@link #stop()} is invoked.
      */
-    private final IdentityHashMap<Runnable, Void> listeners = new IdentityHashMap<>(5);
+    private final Map<Runnable, Void> listeners = new HashMap<>(5);
 
     /**
      * Indicates that operations within the pipeline should stop executing.