Bug 3836 - sonar: Throwable and Error classes should not be caught - part1 60/23160/2
authorRuijing Guo <ruijing.guo@intel.com>
Tue, 23 Jun 2015 08:20:02 +0000 (08:20 +0000)
committerRuijing Guo <ruijing.guo@intel.com>
Thu, 9 Jul 2015 05:30:14 +0000 (05:30 +0000)
Change-Id: Ia994ac86100aca4f31dbe00d9f0a61db786a929a
Signed-off-by: Ruijing Guo <ruijing.guo@intel.com>
renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EndpointManager.java
renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/PolicyManager.java
renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcEndpoint.java
renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexConnectionService.java
renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcEndpointTest.java

index c182b0537704fabd06418f3f4381f500d436eab2..2e85e81f6d492d304731f091a9c8d2bd3e89fae4 100644 (file)
@@ -346,7 +346,7 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
             request.setParams(paramList);
             try {
                 agent.sendRequest(request);
-            } catch (Throwable t) {
+            } catch (Exception e) {
 
             }
 
@@ -618,7 +618,7 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
             resp.setId(req.getId());
             try {
                 agent.sendResponse(resp);
-            } catch (Throwable t) {
+            } catch (Exception e) {
                 LOG.warn("Response {} could not be sent to {}", resp, agent);
             }
 
@@ -642,7 +642,7 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
         public void run() {
             try {
                 ctx.getPeer().sendResponse(resp);
-            } catch (Throwable t) {
+            } catch (Exception e) {
                 // TODO: what to do here
             }
 
index c4eaa8660ddd87e4742b057f40109dea244d85dd..097254c7a976f9a47515f1797fb7350450c1fb59 100644 (file)
@@ -229,7 +229,7 @@ public class PolicyManager implements PolicyListener, RpcBroker.RpcCallback, Aut
             request.setParams(paramsList);
             try {
                 agent.sendRequest(request);
-            } catch (Throwable t) {
+            } catch (Exception e) {
 
             }
         }
@@ -509,8 +509,8 @@ public class PolicyManager implements PolicyListener, RpcBroker.RpcCallback, Aut
         if (response != null) {
             try {
                 endpoint.sendResponse(response);
-            } catch (Throwable t) {
-                LOG.warn("Error sending response {}", t);
+            } catch (Exception e) {
+                LOG.warn("Error sending response {}", e);
             }
         }
 
index 5fd3c84a9d0ddf7804bf238e65cd9d50b3ee7e5e..4f661ef12754d47736c3440619ed6da6df37bc50 100644 (file)
@@ -105,9 +105,9 @@ public class JsonRpcEndpoint implements ChannelFutureListener {
      * @param message The concrete {@link RpcMessage} to send
      * @return SettableFuture&lt;Object&gt; The caller can use the returned
      * object to wait for the response (currently no timeout)
-     * @throws Throwable The concrete message couldn't be serialized and sent
+     * @throws Exception The concrete message couldn't be serialized and sent
      */
-    public SettableFuture<Object> sendRequest(RpcMessage message) throws Throwable {
+    public SettableFuture<Object> sendRequest(RpcMessage message) throws Exception {
         if (messageMap.get(message.getName()) == null) {
                 return null;
         }
@@ -130,9 +130,9 @@ public class JsonRpcEndpoint implements ChannelFutureListener {
      * Send a response to a previous {@link RpcMessage}request
      *
      * @param message The concrete {@link RpcMessage}
-     * @throws Throwable The concrete message couldn't be serialized and sent
+     * @throws Exception The concrete message couldn't be serialized and sent
      */
-    public void  sendResponse (RpcMessage message) throws Throwable {
+    public void  sendResponse (RpcMessage message) throws Exception {
 
         String s = objectMapper.writeValueAsString(message) + "\0";
         logger.trace("sendResponse: {}", s);
index d28cb32b5322091278761e96cbeccdc118f497c2..15d7c34a44655532c1749d010d29696cbe6b1b13 100644 (file)
@@ -650,8 +650,8 @@ public class OpflexConnectionService implements ConnectionService, RpcBroker, Rp
          */
         try {
             endpoint.sendResponse(response);
-        } catch (Throwable e) {
-            logger.error("Throwable for sending {}, {}", message, e);
+        } catch (Exception e) {
+            logger.error("Exception for sending {}, {}", message, e);
         }
     }
 
@@ -717,8 +717,8 @@ public class OpflexConnectionService implements ConnectionService, RpcBroker, Rp
 
         try {
             endpoint.sendRequest(ourId);
-        } catch (Throwable t) {
-            logger.error("Couldn't send Identity {}", t);
+        } catch (Exception e) {
+            logger.error("Couldn't send Identity {}", e);
         }
     }
 
index d1d6f708a922d3f5787f1f82d519c7778d54a9c2..40f083631787523c1b81a3ef47dedb53a9b1298b 100644 (file)
@@ -222,7 +222,7 @@ public class JsonRpcEndpointTest implements RpcBroker, RpcBroker.RpcCallback {
             assertTrue(result.toString().contains("method"));
             assertTrue(result.toString().contains("params"));
             channel.finish();
-        } catch ( Throwable e ) {
+        } catch ( Exception e ) {
             fail();
         }
     }
@@ -270,7 +270,7 @@ public class JsonRpcEndpointTest implements RpcBroker, RpcBroker.RpcCallback {
             Object tmp = lf.get();
             assertTrue(tmp instanceof JsonRpcEndpointTest.OpflexTest);
             channel.finish();
-         } catch ( Throwable e ) {
+         } catch ( Exception e ) {
             fail();
         }
     }