Bug 7521: Convert byte[] to ShardManagerSnapshot in DatastoreSnapshot
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / DataChangeListenerRegistrationActor.java
index 2632498a03a9db3a1f6fd43573e3eb3ce15713f1..89062dc83c1735545b612ed767846688017a6567 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.controller.cluster.datastore;
 import akka.actor.PoisonPill;
 import akka.actor.Props;
 import akka.japi.Creator;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
 import org.opendaylight.controller.cluster.datastore.messages.CloseDataChangeListenerRegistration;
 import org.opendaylight.controller.cluster.datastore.messages.CloseDataChangeListenerRegistrationReply;
@@ -38,20 +39,27 @@ public class DataChangeListenerRegistrationActor extends AbstractUntypedActor {
         }
     }
 
-    public static Props props(
-        final ListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>> registration) {
+    public static Props props(final ListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier,
+            NormalizedNode<?, ?>>> registration) {
         return Props.create(new DataChangeListenerRegistrationCreator(registration));
     }
 
     private void closeListenerRegistration() {
         registration.close();
-        getSender().tell(CloseDataChangeListenerRegistrationReply.INSTANCE, getSelf());
+
+        if (isValidSender(getSender())) {
+            getSender().tell(CloseDataChangeListenerRegistrationReply.INSTANCE, getSelf());
+        }
+
         getSelf().tell(PoisonPill.getInstance(), getSelf());
     }
 
     private static class DataChangeListenerRegistrationCreator
                                             implements Creator<DataChangeListenerRegistrationActor> {
         private static final long serialVersionUID = 1L;
+
+        @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "This field is not Serializable but we don't "
+                + "create remote instances of this actor and thus don't need it to be Serializable.")
         final ListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier,
                                                            NormalizedNode<?, ?>>> registration;