From 5b3c73132a0745f93be4d2f798a2802e62f7bd52 Mon Sep 17 00:00:00 2001 From: Moiz Raja Date: Mon, 8 Jun 2015 19:22:28 -0700 Subject: [PATCH] Avoid ClassCastException in remote-rpc-connector Change-Id: Idc41c2d4409ac321bc47e48150c801166999ce17 Signed-off-by: Moiz Raja (cherry picked from commit 6e0016fba14509df5eff3314c70401c5491b2ccc) --- .../remote/rpc/RemoteRpcImplementation.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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); -- 2.36.6