X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fnetconf-topology-singleton%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Ftopology%2Fsingleton%2Fimpl%2FProxyDOMRpcService.java;h=f972e4568454e32207e24980d97aa2f6ab6db527;hb=3eac4fad8be9aae42fd76037e1c0a8ef5dc7b608;hp=33fa7b96e7443f83e4e0bb1fe133c5b4699a8657;hpb=fb24733359ca4429adf88aa0c9fd5d2500d411fb;p=netconf.git diff --git a/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/ProxyDOMRpcService.java b/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/ProxyDOMRpcService.java index 33fa7b96e7..f972e45684 100644 --- a/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/ProxyDOMRpcService.java +++ b/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/ProxyDOMRpcService.java @@ -13,7 +13,6 @@ import akka.actor.ActorSystem; import akka.dispatch.OnComplete; import akka.pattern.Patterns; import akka.util.Timeout; -import com.google.common.base.Function; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.SettableFuture; @@ -66,58 +65,39 @@ public class ProxyDOMRpcService implements DOMRpcService { final NormalizedNodeMessage normalizedNodeMessage = new NormalizedNodeMessage(YangInstanceIdentifier.EMPTY, input); - final Future scalaFuture = - Patterns.ask(masterActorRef, - new InvokeRpcMessage(new SchemaPathMessage(type), normalizedNodeMessage), - actorResponseWaitTime); + final Future scalaFuture = Patterns.ask(masterActorRef, + new InvokeRpcMessage(new SchemaPathMessage(type), normalizedNodeMessage), actorResponseWaitTime); final SettableFuture settableFuture = SettableFuture.create(); - final CheckedFuture checkedFuture = Futures.makeChecked(settableFuture, - new Function() { - - @Nullable - @Override - public DOMRpcException apply(@Nullable final Exception exception) { - return new ClusteringRpcException(id + ": Exception during remote rpc invocation.", - exception); - } - }); - scalaFuture.onComplete(new OnComplete() { @Override - public void onComplete(final Throwable failure, final Object success) throws Throwable { + public void onComplete(final Throwable failure, final Object response) { if (failure != null) { settableFuture.setException(failure); return; } - if (success instanceof Throwable) { - settableFuture.setException((Throwable) success); - return; - } - if (success instanceof EmptyResultResponse || success == null) { + + if (response instanceof EmptyResultResponse) { settableFuture.set(null); return; } - final Collection errors = ((InvokeRpcMessageReply) success).getRpcErrors(); + + final Collection errors = ((InvokeRpcMessageReply) response).getRpcErrors(); final NormalizedNodeMessage normalizedNodeMessageResult = - ((InvokeRpcMessageReply) success).getNormalizedNodeMessage(); + ((InvokeRpcMessageReply) response).getNormalizedNodeMessage(); final DOMRpcResult result; if (normalizedNodeMessageResult == null) { result = new DefaultDOMRpcResult(errors); } else { - if (errors == null) { - result = new DefaultDOMRpcResult(normalizedNodeMessageResult.getNode()); - } else { - result = new DefaultDOMRpcResult(normalizedNodeMessageResult.getNode(), errors); - } + result = new DefaultDOMRpcResult(normalizedNodeMessageResult.getNode(), errors); } settableFuture.set(result); } }, actorSystem.dispatcher()); - return checkedFuture; - + return Futures.makeChecked(settableFuture, + ex -> new ClusteringRpcException(id + ": Exception during remote rpc invocation.", ex)); } @Nonnull