Eliminate dead letters message when there's no sender
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / common / actor / AbstractUntypedActor.java
index dffb610..ca303a5 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.controller.cluster.common.actor;
 
+import akka.actor.ActorRef;
 import akka.actor.UntypedActor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -42,4 +43,10 @@ public abstract class AbstractUntypedActor extends UntypedActor {
         LOG.debug("Received unhandled message {}", message);
         unhandled(message);
     }
+
+    protected boolean isValidSender(ActorRef sender) {
+        // If the caller passes in a null sender (ActorRef.noSender()), akka translates that to the
+        // deadLetters actor.
+        return sender != null && !getContext().system().deadLetters().equals(sender);
+    }
 }