If a listener throws an exception, make sure to log it and proceed
as if nothing happened.
JIRA: MDSAL-544
Change-Id: I0ca54bb5c517115b840ad03ea24d442c7762ff05
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
bc58fd6b46acb6f94d6b9395a67f7112d134f0c1)
import org.opendaylight.mdsal.dom.api.DOMNotification;
import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
import org.opendaylight.mdsal.dom.api.DOMNotification;
import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
+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.
+ * A single notification event in the disruptor ringbuffer. These objects are reused, so they do have mutable state.
*/
final class DOMNotificationRouterEvent {
*/
final class DOMNotificationRouterEvent {
+ private static final Logger LOG = LoggerFactory.getLogger(DOMNotificationRouterEvent.class);
+
static final EventFactory<DOMNotificationRouterEvent> FACTORY = DOMNotificationRouterEvent::new;
private Collection<AbstractListenerRegistration<? extends DOMNotificationListener>> subscribers;
static final EventFactory<DOMNotificationRouterEvent> FACTORY = DOMNotificationRouterEvent::new;
private Collection<AbstractListenerRegistration<? extends DOMNotificationListener>> subscribers;
+ @SuppressWarnings("checkstyle:illegalCatch")
void deliverNotification() {
void deliverNotification() {
- for (AbstractListenerRegistration<? extends DOMNotificationListener> r : subscribers) {
- if (r.notClosed()) {
- r.getInstance().onNotification(notification);
+ for (AbstractListenerRegistration<? extends DOMNotificationListener> reg : subscribers) {
+ if (reg.notClosed()) {
+ final DOMNotificationListener listener = reg.getInstance();
+ try {
+ listener.onNotification(notification);
+ } catch (Exception e) {
+ LOG.warn("Listener {} failed during notification delivery", listener, e);
+ }
void setFuture() {
future.set(null);
}
void setFuture() {
future.set(null);
}
-
-}
\ No newline at end of file