From: Kamal Rameshan Date: Fri, 13 Nov 2015 19:26:21 +0000 (-0800) Subject: Bug-4636: NotificationSubscriber's exception prevents notifications to other listeners X-Git-Tag: release/beryllium~157 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=ddf67b3a8626524b4e0e509bec62f73702ee5453;hp=ee23f5cbab05e00052d56fdef0613f7df5e8b891 Bug-4636: NotificationSubscriber's exception prevents notifications to other listeners Catch the exception and log it with enough context. Change-Id: I23c248c59753008e6d09155513b2dba108fbccbf Signed-off-by: Kamal Rameshan Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterEvent.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterEvent.java index 65c7166ac9..85f93a6238 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterEvent.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterEvent.java @@ -15,12 +15,15 @@ import java.util.Collection; import org.opendaylight.controller.md.sal.dom.api.DOMNotification; import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener; import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A single notification event in the disruptor ringbuffer. These objects are reused, * so they do have mutable state. */ final class DOMNotificationRouterEvent { + private static final Logger LOG = LoggerFactory.getLogger(DOMNotificationRouterEvent.class); public static final EventFactory FACTORY = new EventFactory() { @Override public DOMNotificationRouterEvent newInstance() { @@ -45,9 +48,13 @@ final class DOMNotificationRouterEvent { void deliverNotification() { for (ListenerRegistration r : subscribers) { - final DOMNotificationListener l = r.getInstance(); - if (l != null) { - l.onNotification(notification); + 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); + } } } }