Be mindful of non-existent actors 72/97572/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 21 Sep 2021 09:49:06 +0000 (11:49 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 21 Sep 2021 09:49:06 +0000 (11:49 +0200)
We have observed the following splat in SFT:

java.lang.NullPointerException: null
        at org.opendaylight.controller.eos.akka.registry.listener.type.EntityTypeListenerRegistry.onUnregisterListener(EntityTypeListenerRegistry.java:69) ~[bundleFile:?]
        at akka.actor.typed.javadsl.BuiltReceive.receive(ReceiveBuilder.scala:213) ~[bundleFile:?]

This this by checking whether we actually removed a listener.

Change-Id: Ifc80ae650db05fd1031af074c694588034f6903a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/eos-dom-akka/src/main/java/org/opendaylight/controller/eos/akka/registry/listener/type/EntityTypeListenerRegistry.java

index e4f7b48d04dcbb7334927902ef9519f719663ac5..a6183a8f1c3e403ce7171df671912f35dbf75611 100644 (file)
@@ -66,7 +66,10 @@ public class EntityTypeListenerRegistry extends AbstractBehavior<TypeListenerReg
     private Behavior<TypeListenerRegistryCommand> onUnregisterListener(final UnregisterListener command) {
         LOG.debug("Stopping entity type listener actor for: {}", command.getEntityType());
 
-        spawnedListenerActors.remove(command.getDelegateListener()).tell(TerminateListener.INSTANCE);
+        final ActorRef<TypeListenerCommand> actor = spawnedListenerActors.remove(command.getDelegateListener());
+        if (actor != null) {
+            actor.tell(TerminateListener.INSTANCE);
+        }
         return this;
     }