From: Robert Varga Date: Wed, 16 Apr 2014 09:07:46 +0000 (+0200) Subject: BUG-731: do not catch Throwable X-Git-Tag: autorelease-tag-v20140601202136_82eb3f9~213^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=b22f57765f9968f49d3fe1c0e5c00c4ffa81cd62 BUG-731: do not catch Throwable This fixes the bad practice of catching Throwable, and uses logger instead of e.printStackTrace(). Change-Id: I44541f7c71dda0bcf633d22d9a46b3959ed3001f Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/samples/l2switch/implementation/src/main/java/org/opendaylight/controller/sample/l2switch/md/packet/PacketHandler.java b/opendaylight/md-sal/samples/l2switch/implementation/src/main/java/org/opendaylight/controller/sample/l2switch/md/packet/PacketHandler.java index 753de4aa85..ecf116b171 100644 --- a/opendaylight/md-sal/samples/l2switch/implementation/src/main/java/org/opendaylight/controller/sample/l2switch/md/packet/PacketHandler.java +++ b/opendaylight/md-sal/samples/l2switch/implementation/src/main/java/org/opendaylight/controller/sample/l2switch/md/packet/PacketHandler.java @@ -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); } } diff --git a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandler.java b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandler.java index eb6fd2722a..1616857949 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandler.java +++ b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandler.java @@ -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 +}