Fix findbugs violations in md-sal - part 1
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / md / sal / dom / broker / impl / DOMNotificationRouterEvent.java
index 85f93a6238fdf8ce134474a0a04a60f5eadc0568..a1d5faee7ccd113953448db7da8001766c443692 100644 (file)
@@ -24,12 +24,7 @@ import org.slf4j.LoggerFactory;
  */
 final class DOMNotificationRouterEvent {
     private static final Logger LOG = LoggerFactory.getLogger(DOMNotificationRouterEvent.class);
-    public static final EventFactory<DOMNotificationRouterEvent> FACTORY = new EventFactory<DOMNotificationRouterEvent>() {
-        @Override
-        public DOMNotificationRouterEvent newInstance() {
-            return new DOMNotificationRouterEvent();
-        }
-    };
+    public static final EventFactory<DOMNotificationRouterEvent> FACTORY = DOMNotificationRouterEvent::new;
 
     private Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers;
     private DOMNotification notification;
@@ -39,7 +34,10 @@ final class DOMNotificationRouterEvent {
         // Hidden on purpose, initialized in initialize()
     }
 
-    ListenableFuture<Void> initialize(final DOMNotification notification, final Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers) {
+    @SuppressWarnings("checkstyle:hiddenField")
+    ListenableFuture<Void> initialize(final DOMNotification notification,
+                                      final Collection<ListenerRegistration<? extends DOMNotificationListener>>
+                                              subscribers) {
         this.notification = Preconditions.checkNotNull(notification);
         this.subscribers = Preconditions.checkNotNull(subscribers);
         this.future = SettableFuture.create();
@@ -47,20 +45,22 @@ final class DOMNotificationRouterEvent {
     }
 
     void deliverNotification() {
+        LOG.trace("Start delivery of notification {}", notification);
         for (ListenerRegistration<? extends DOMNotificationListener> r : subscribers) {
             final DOMNotificationListener listener = r.getInstance();
             if (listener != null) {
-                try {
-                    listener.onNotification(notification);
-                } catch (Exception e) {
-                    LOG.error("Delivery of notification {} caused an error in listener {}", notification, listener, e);
-                }
+                LOG.trace("Notifying listener {}", listener);
+                listener.onNotification(notification);
+                LOG.trace("Listener notification completed");
             }
         }
+        LOG.trace("Delivery completed");
     }
 
     void setFuture() {
         future.set(null);
+        notification = null;
+        subscribers = null;
+        future = null;
     }
-
 }
\ No newline at end of file