Merge "Bug 7491 - Ignore exceptions during invoking notification listeners"
authorTomas Cere <tcere@cisco.com>
Tue, 17 Jan 2017 09:18:07 +0000 (09:18 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 17 Jan 2017 09:18:07 +0000 (09:18 +0000)
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceNotificationService.java

index 68805c40d4bcbff8fdb8a594d6fab11411c3c017..8838ef15ee01268704c192ba33bf17ff756f6910 100644 (file)
@@ -18,16 +18,25 @@ import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class NetconfDeviceNotificationService implements DOMNotificationService {
 
+    private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceNotificationService.class);
+
     private final Multimap<SchemaPath, DOMNotificationListener> listeners = HashMultimap.create();
 
     // Notification publish is very simple and hijacks the thread of the caller
     // TODO shouldnt we reuse the implementation for notification router from sal-broker-impl ?
     public synchronized void publishNotification(final DOMNotification notification) {
         for (final DOMNotificationListener domNotificationListener : listeners.get(notification.getType())) {
-            domNotificationListener.onNotification(notification);
+            try {
+                domNotificationListener.onNotification(notification);
+            } catch (final Exception e) {
+                LOG.warn("Listener {} threw an uncaught exception during processing notification {}",
+                        domNotificationListener, notification, e);
+            }
         }
     }