Cleanup ActorProxyNetconfServiceFacade
[netconf.git] / netconf / netconf-topology-singleton / src / main / java / org / opendaylight / netconf / topology / singleton / impl / netconf / ActorProxyNetconfServiceFacade.java
index f6195e3d8b6c2b31f60325c6de04aa7cbb075f71..b27aa8ba3f0ddf1f80b03021efb242c9d2547ffa 100644 (file)
@@ -15,14 +15,13 @@ import akka.dispatch.OnComplete;
 import akka.pattern.AskTimeoutException;
 import akka.pattern.Patterns;
 import akka.util.Timeout;
+import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 import java.util.Optional;
-import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
@@ -135,14 +134,14 @@ public class ActorProxyNetconfServiceFacade implements ProxyNetconfServiceFacade
     }
 
     @Override
-    public ListenableFuture<Optional<NormalizedNode<?, ?>>> get(final YangInstanceIdentifier path) {
+    public ListenableFuture<Optional<NormalizedNode>> get(final YangInstanceIdentifier path) {
         LOG.debug("{}: Get {} {} via actor {}", id, OPERATIONAL, path, masterActor);
         final Future<Object> future = Patterns.ask(masterActor, new GetRequest(path), askTimeout);
         return read(future, OPERATIONAL, path);
     }
 
     @Override
-    public ListenableFuture<Optional<NormalizedNode<?, ?>>> get(final YangInstanceIdentifier path,
+    public ListenableFuture<Optional<NormalizedNode>> get(final YangInstanceIdentifier path,
             final List<YangInstanceIdentifier> fields) {
         LOG.debug("{}: Get {} {} with fields {} via actor {}", id, OPERATIONAL, path, fields, masterActor);
         final Future<Object> future = Patterns.ask(masterActor, new GetWithFieldsRequest(path, fields), askTimeout);
@@ -150,14 +149,14 @@ public class ActorProxyNetconfServiceFacade implements ProxyNetconfServiceFacade
     }
 
     @Override
-    public ListenableFuture<Optional<NormalizedNode<?, ?>>> getConfig(final YangInstanceIdentifier path) {
+    public ListenableFuture<Optional<NormalizedNode>> getConfig(final YangInstanceIdentifier path) {
         LOG.debug("{}: GetConfig {} {} via actor {}", id, CONFIGURATION, path, masterActor);
         final Future<Object> future = Patterns.ask(masterActor, new GetConfigRequest(path), askTimeout);
         return read(future, CONFIGURATION, path);
     }
 
     @Override
-    public ListenableFuture<Optional<NormalizedNode<?, ?>>> getConfig(final YangInstanceIdentifier path,
+    public ListenableFuture<Optional<NormalizedNode>> getConfig(final YangInstanceIdentifier path,
             final List<YangInstanceIdentifier> fields) {
         LOG.debug("{}: GetConfig {} {} with fields {} via actor {}", id, CONFIGURATION, path, fields, masterActor);
         final Future<Object> future = Patterns.ask(masterActor,
@@ -167,7 +166,7 @@ public class ActorProxyNetconfServiceFacade implements ProxyNetconfServiceFacade
 
     @Override
     public ListenableFuture<? extends DOMRpcResult> merge(final LogicalDatastoreType store,
-            final YangInstanceIdentifier path, final NormalizedNode<?, ?> data,
+            final YangInstanceIdentifier path, final NormalizedNode data,
             final Optional<ModifyAction> defaultOperation) {
         LOG.debug("{}: Merge {} {} via actor {}", id, store, path, masterActor);
         masterActor.tell(new MergeEditConfigRequest(
@@ -178,7 +177,7 @@ public class ActorProxyNetconfServiceFacade implements ProxyNetconfServiceFacade
 
     @Override
     public ListenableFuture<? extends DOMRpcResult> replace(final LogicalDatastoreType store,
-            final YangInstanceIdentifier path, final NormalizedNode<?, ?> data,
+            final YangInstanceIdentifier path, final NormalizedNode data,
             final Optional<ModifyAction> defaultOperation) {
         LOG.debug("{}: Replace {} {} via actor {}", id, store, path, masterActor);
 
@@ -189,7 +188,7 @@ public class ActorProxyNetconfServiceFacade implements ProxyNetconfServiceFacade
 
     @Override
     public ListenableFuture<? extends DOMRpcResult> create(final LogicalDatastoreType store,
-            final YangInstanceIdentifier path, final NormalizedNode<?, ?> data,
+            final YangInstanceIdentifier path, final NormalizedNode data,
             final Optional<ModifyAction> defaultOperation) {
         LOG.debug("{}: Create {} {} via actor {}", id, store, path, masterActor);
         masterActor.tell(new CreateEditConfigRequest(
@@ -244,14 +243,13 @@ public class ActorProxyNetconfServiceFacade implements ProxyNetconfServiceFacade
     }
 
     @Override
-    public @NonNull Object getDeviceId() {
+    public Object getDeviceId() {
         return id;
     }
 
-    private SettableFuture<Optional<NormalizedNode<?, ?>>> read(final Future<Object> future,
-                                                                final LogicalDatastoreType store,
-                                                                final YangInstanceIdentifier path) {
-        final SettableFuture<Optional<NormalizedNode<?, ?>>> settableFuture = SettableFuture.create();
+    private SettableFuture<Optional<NormalizedNode>> read(final Future<Object> future, final LogicalDatastoreType store,
+                                                          final YangInstanceIdentifier path) {
+        final SettableFuture<Optional<NormalizedNode>> settableFuture = SettableFuture.create();
         future.onComplete(new OnComplete<>() {
             @Override
             public void onComplete(final Throwable failure, final Object response) {
@@ -285,21 +283,16 @@ public class ActorProxyNetconfServiceFacade implements ProxyNetconfServiceFacade
         return settableFuture;
     }
 
-    @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
-        justification = "https://github.com/spotbugs/spotbugs/issues/811")
     private Throwable processFailure(final Throwable failure) {
         return failure instanceof AskTimeoutException
             ? NetconfTopologyUtils.createMasterIsDownException(id, (Exception) failure) : failure;
     }
 
-    private ListenableFuture<? extends DOMRpcResult> createResult() {
-        final SettableFuture<DOMRpcResult> settableFuture = SettableFuture.create();
-        settableFuture.set(new DefaultDOMRpcResult());
-        return settableFuture;
+    // FIXME: this is being used in contexts where we should be waiting for a reply
+    private static ListenableFuture<? extends DOMRpcResult> createResult() {
+        return Futures.immediateFuture(new DefaultDOMRpcResult());
     }
 
-    @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
-        justification = "https://github.com/spotbugs/spotbugs/issues/811")
     private static DOMRpcResult mapInvokeRpcMessageReplyToDOMRpcResult(final InvokeRpcMessageReply reply) {
         if (reply.getNormalizedNodeMessage() == null) {
             return new DefaultDOMRpcResult(new ArrayList<>(reply.getRpcErrors()));