X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Fimpl%2FGeneratedListenerRegistration.java;h=5325ed3c3af63b59429de62076647903114717cb;hp=cc8471f7b4e5e5388cb6736b4f89a84f44cb7fc6;hb=5bd4e3c091c2d309243b258eb014014db284f025;hpb=5bcdfba60fc0b8b51ce15dacfef4f50e9f4f29f7 diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/GeneratedListenerRegistration.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/GeneratedListenerRegistration.java index cc8471f7b4..5325ed3c3a 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/GeneratedListenerRegistration.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/GeneratedListenerRegistration.java @@ -12,26 +12,28 @@ import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.NotificationListener; -public class GeneratedListenerRegistration extends AbstractObjectRegistration implements ListenerRegistration { - private final NotificationInvoker _invoker; - - public NotificationInvoker getInvoker() { - return this._invoker; - } +import com.google.common.base.Preconditions; +class GeneratedListenerRegistration extends AbstractObjectRegistration implements ListenerRegistration { private NotificationBrokerImpl notificationBroker; + private final NotificationInvoker invoker; public GeneratedListenerRegistration(final NotificationListener instance, final NotificationInvoker invoker, final NotificationBrokerImpl broker) { super(instance); - this._invoker = invoker; - this.notificationBroker = broker; + this.invoker = Preconditions.checkNotNull(invoker); + this.notificationBroker = Preconditions.checkNotNull(broker); + } + + public NotificationInvoker getInvoker() { + // There is a race with NotificationBrokerImpl: + // the invoker can be closed here + return invoker; } @Override protected void removeRegistration() { - this.notificationBroker.unregisterListener(this); - this.notificationBroker = null; - NotificationInvoker _invoker = this.getInvoker(); - _invoker.close(); + notificationBroker.unregisterListener(this); + notificationBroker = null; + invoker.close(); } }