Convert rfc8040 ListenerAdapter to DOMDataTreeChangeListener
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / streams / listeners / AbstractCommonSubscriber.java
index ea3ad270ff44d58bb33d2664d6dbba53aad78e05..6e2004eea4b571dc727043d476262dcd21278c25 100644 (file)
@@ -29,8 +29,8 @@ abstract class AbstractCommonSubscriber extends AbstractQueryParams implements B
 
     @SuppressWarnings("rawtypes")
     private EventBusChangeRecorder eventBusChangeRecorder;
-    @SuppressWarnings("rawtypes")
-    private ListenerRegistration registration;
+
+    private volatile ListenerRegistration<?> registration;
 
     /**
      * Creating {@link EventBus}.
@@ -51,8 +51,10 @@ abstract class AbstractCommonSubscriber extends AbstractQueryParams implements B
 
     @Override
     public final void close() throws Exception {
-        this.registration.close();
-        this.registration = null;
+        if (this.registration != null) {
+            this.registration.close();
+            this.registration = null;
+        }
 
         deleteDataInDS();
         unregister();
@@ -93,8 +95,7 @@ abstract class AbstractCommonSubscriber extends AbstractQueryParams implements B
      * @param registration
      *            DOMDataChangeListener registration
      */
-    @SuppressWarnings("rawtypes")
-    public void setRegistration(final ListenerRegistration registration) {
+    public void setRegistration(final ListenerRegistration<?> registration) {
         this.registration = registration;
     }