From: Moiz Raja Date: Tue, 9 Jun 2015 02:22:28 +0000 (-0700) Subject: Avoid ClassCastException in remote-rpc-connector X-Git-Tag: release/lithium~47 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=6e0016fba14509df5eff3314c70401c5491b2ccc Avoid ClassCastException in remote-rpc-connector Change-Id: Idc41c2d4409ac321bc47e48150c801166999ce17 Signed-off-by: Moiz Raja --- diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcImplementation.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcImplementation.java index 23d1e85e23..2a4ea2e3e6 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcImplementation.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcImplementation.java @@ -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 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 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);