BUG-731: do not catch Throwable 27/6227/1
authorRobert Varga <rovarga@cisco.com>
Wed, 16 Apr 2014 09:07:46 +0000 (11:07 +0200)
committerRobert Varga <rovarga@cisco.com>
Wed, 16 Apr 2014 09:10:33 +0000 (11:10 +0200)
This fixes the bad practice of catching Throwable, and uses logger
instead of e.printStackTrace().

Change-Id: I44541f7c71dda0bcf633d22d9a46b3959ed3001f
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/samples/l2switch/implementation/src/main/java/org/opendaylight/controller/sample/l2switch/md/packet/PacketHandler.java
opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandler.java

index 753de4aa856f424e0b8b99bb157319b91e4ca6f4..ecf116b171993659a0c42ae5e1ba9e21c19ea24d 100644 (file)
@@ -86,8 +86,8 @@ public class PacketHandler implements PacketProcessingListener {
 
       handleEthernetPacket(packet, ingress);
 
-    } catch(Throwable _e) {
-      _e.printStackTrace();
+    } catch(Exception e) {
+      _logger.error("Failed to handle packet {}", packetReceived, e);
     }
   }
 
index eb6fd2722a4cbdb9860ec4faf57462403ff02fbd..1616857949d91c0678e7740ae2b277bfc12b25a0 100644 (file)
@@ -90,10 +90,10 @@ class ConfigPersisterNotificationListener implements NotificationListener {
         if (notification instanceof CommitJMXNotification) {
             try {
                 handleAfterCommitNotification((CommitJMXNotification) notification);
-            } catch (Throwable e) {
+            } catch (Exception e) {
                 // log exceptions from notification Handler here since
                 // notificationBroadcastSupport logs only DEBUG level
-                logger.warn("Exception occured during notification handling: ", e);
+                logger.warn("Failed to handle notification {}", notification, e);
                 throw e;
             }
         } else {
@@ -110,4 +110,4 @@ class ConfigPersisterNotificationListener implements NotificationListener {
             throw new RuntimeException("Unable to persist configuration snapshot", e);
         }
     }
-}
\ No newline at end of file
+}