Avoid ClassCastException in remote-rpc-connector 15/22215/1
authorMoiz Raja <moraja@cisco.com>
Tue, 9 Jun 2015 02:22:28 +0000 (19:22 -0700)
committerTom Pantelis <tpanteli@brocade.com>
Tue, 9 Jun 2015 16:11:55 +0000 (16:11 +0000)
Change-Id: Idc41c2d4409ac321bc47e48150c801166999ce17
Signed-off-by: Moiz Raja <moraja@cisco.com>
(cherry picked from commit 6e0016fba14509df5eff3314c70401c5491b2ccc)

opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcImplementation.java

index 23d1e85e23c355721c31e22bda7d6e7232c9cfd1..2a4ea2e3e6d6208a371cdb163de9ec3344df89df 100644 (file)
@@ -64,10 +64,14 @@ public class RemoteRpcImplementation implements DOMRpcImplementation {
                         LOG.debug("Detailed Error", failure);
                     }
 
-                    final String message = String.format("Execution of RPC %s failed",  rpcMsg.getRpc());
-                    Collection<RpcError> errors = ((RpcErrorsException)failure).getRpcErrors();
-                    if(errors == null || errors.size() == 0) {
-                        errors = Arrays.asList(RpcResultBuilder.newError(ErrorType.RPC, null, message));
+                    final String message = String.format("Execution of RPC %s failed because of %s",
+                            rpcMsg.getRpc(), failure.getMessage());
+                    Collection<RpcError> errors = Arrays.asList(RpcResultBuilder.newError(ErrorType.RPC, null, message));
+                    if(failure instanceof RpcErrorsException) {
+                        errors = ((RpcErrorsException) failure).getRpcErrors();
+                        if (errors == null || errors.size() == 0) {
+                            errors = Arrays.asList(RpcResultBuilder.newError(ErrorType.RPC, null, message));
+                        }
                     }
                     final DOMRpcResult rpcResult = new DefaultDOMRpcResult(errors);