[CORD-2734] Protect SR executor from exceptions

Change-Id: I8a6f98aa242243bf45797aa690a2b90d2b61dd4d
diff --git a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
index f661add..c3980b2 100644
--- a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
+++ b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
@@ -1040,8 +1040,8 @@
     private class InternalEventHandler implements Runnable {
         @Override
         public void run() {
-            try {
-                while (true) {
+            while (true) {
+                try {
                     @SuppressWarnings("rawtypes")
                     Event event;
                     synchronized (THREAD_SCHED_LOCK) {
@@ -1070,7 +1070,7 @@
                             processDeviceAdded((Device) event.subject());
                         } else {
                             log.info("Processing device event {} for unavailable device {}",
-                                    event.type(), ((Device) event.subject()).id());
+                                     event.type(), ((Device) event.subject()).id());
                             processDeviceRemoved((Device) event.subject());
                         }
                     } else if (event.type() == DeviceEvent.Type.PORT_ADDED) {
@@ -1094,10 +1094,10 @@
                     } else {
                         log.warn("Unhandled event type: {}", event.type());
                     }
+                } catch (Exception e) {
+                    log.error("SegmentRouting event handler thread thrown an exception: {}",
+                              e.getMessage(), e);
                 }
-            } catch (Exception e) {
-                log.error("SegmentRouting event handler "
-                        + "thread thrown an exception: {}", e);
             }
         }
     }