package org.opendaylight.controller.cluster.common.actor;
+import akka.actor.ActorRef;
import akka.actor.UntypedActor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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);
+ }
}
import org.opendaylight.controller.cluster.datastore.messages.DataChanged;
import org.opendaylight.controller.cluster.datastore.messages.DataChangedReply;
import org.opendaylight.controller.cluster.datastore.messages.EnableNotification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
LOG.error( String.format( "Error notifying listener %s", this.listener ), e );
}
- // It seems the sender is never null but it doesn't hurt to check. If the caller passes in
- // a null sender (ActorRef.noSender()), akka translates that to the deadLetters actor.
- if(getSender() != null && !getContext().system().deadLetters().equals(getSender())) {
+ if(isValidSender(getSender())) {
getSender().tell(DataChangedReply.INSTANCE, getSelf());
}
}
private void closeListenerRegistration() {
registration.close();
- getSender().tell(CloseDataChangeListenerRegistrationReply.INSTANCE, getSelf());
+
+ if(isValidSender(getSender())) {
+ getSender().tell(CloseDataChangeListenerRegistrationReply.INSTANCE, getSelf());
+ }
+
getSelf().tell(PoisonPill.getInstance(), getSelf());
}
protected void handleReceive(Object message) throws Exception {
if (message instanceof CloseDataTreeChangeListenerRegistration) {
registration.close();
- getSender().tell(CloseDataTreeChangeListenerRegistrationReply.getInstance(), getSelf());
+ if(isValidSender(getSender())) {
+ getSender().tell(CloseDataTreeChangeListenerRegistrationReply.getInstance(), getSelf());
+ }
+
getSelf().tell(PoisonPill.getInstance(), getSelf());
} else {
unknownMessage(message);