Improve LocalProxyTransaction.doExists()
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / databroker / actors / dds / LocalProxyTransaction.java
index 561870839d9f86c856d7d2a03e368e90e0fd21d2..cc09265b5da3cb986c1e00d19831de07b8d61c2b 100644 (file)
@@ -32,8 +32,8 @@ import org.opendaylight.yangtools.util.concurrent.FluentFutures;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -77,7 +77,7 @@ abstract class LocalProxyTransaction extends AbstractProxyTransaction {
 
     @Override
     final FluentFuture<Boolean> doExists(final YangInstanceIdentifier path) {
-        return FluentFutures.immediateFluentFuture(readOnlyView().readNode(path).isPresent());
+        return FluentFutures.immediateBooleanFluentFuture(readOnlyView().readNode(path).isPresent());
     }
 
     @Override
@@ -104,22 +104,18 @@ abstract class LocalProxyTransaction extends AbstractProxyTransaction {
         // Note we delay completion of read requests to limit the scope at which the client can run, as they have
         // listeners, which we do not want to execute while we are reconnecting.
         if (request instanceof ReadTransactionRequest) {
-            final YangInstanceIdentifier path = ((ReadTransactionRequest) request).getPath();
-            final Optional<NormalizedNode> result = readOnlyView().readNode(path);
             if (callback != null) {
-                // XXX: FB does not see that callback is final, on stack and has be check for non-null.
-                final Consumer<Response<?, ?>> fbIsStupid = requireNonNull(callback);
-                executeInActor(() -> fbIsStupid.accept(new ReadTransactionSuccess(request.getTarget(),
+                final YangInstanceIdentifier path = ((ReadTransactionRequest) request).getPath();
+                final Optional<NormalizedNode> result = readOnlyView().readNode(path);
+                executeInActor(() -> callback.accept(new ReadTransactionSuccess(request.getTarget(),
                     request.getSequence(), result)));
             }
             return true;
         } else if (request instanceof ExistsTransactionRequest) {
-            final YangInstanceIdentifier path = ((ExistsTransactionRequest) request).getPath();
-            final boolean result = readOnlyView().readNode(path).isPresent();
             if (callback != null) {
-                // XXX: FB does not see that callback is final, on stack and has be check for non-null.
-                final Consumer<Response<?, ?>> fbIsStupid = requireNonNull(callback);
-                executeInActor(() -> fbIsStupid.accept(new ExistsTransactionSuccess(request.getTarget(),
+                final YangInstanceIdentifier path = ((ExistsTransactionRequest) request).getPath();
+                final boolean result = readOnlyView().readNode(path).isPresent();
+                executeInActor(() -> callback.accept(new ExistsTransactionSuccess(request.getTarget(),
                     request.getSequence(), result)));
             }
             return true;
@@ -222,7 +218,7 @@ abstract class LocalProxyTransaction extends AbstractProxyTransaction {
     }
 
     private static void throwUnhandledRequest(final TransactionRequest<?> request) {
-        throw new IllegalArgumentException("Unhandled request" + request);
+        throw new IllegalArgumentException("Unhandled request " + request);
     }
 
     void sendAbort(final TransactionRequest<?> request, final Consumer<Response<?, ?>> callback) {