sal-distributed-datastore: use lambdas 85/57185/2
authorStephen Kitt <skitt@redhat.com>
Tue, 16 May 2017 15:51:25 +0000 (17:51 +0200)
committerRobert Varga <nite@hq.sk>
Wed, 17 May 2017 09:04:10 +0000 (09:04 +0000)
This series of patches uses lambdas instead of anonymous classes for
functional interfaces when possible. Lambdas are replaced with method
references when appropriate.

Change-Id: Ib397cbe0e0179f2f47ef10f13301b604dc6db88b
Signed-off-by: Stephen Kitt <skitt@redhat.com>
16 files changed:
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractDataStoreClientActor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/LocalProxyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractFrontendHistory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CompositeDataTreeCohort.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/RemoteTransactionContextSupport.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipListenerSupport.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/ShardedDataTreeActor.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ConcurrentDOMDataBrokerTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeMocking.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerTest.java

index 5e7fade8eb38e4eec482c213fa74f4892553841a..1143bab10c39993f1d51672e6543ed94ea5a2a9a 100644 (file)
@@ -24,7 +24,7 @@ import scala.concurrent.Await;
 import scala.concurrent.duration.Duration;
 
 public abstract class AbstractDataStoreClientActor extends AbstractClientActor {
 import scala.concurrent.duration.Duration;
 
 public abstract class AbstractDataStoreClientActor extends AbstractClientActor {
-    private static final Function1<ActorRef, ?> GET_CLIENT_FACTORY = ExplicitAsk.toScala(t -> new GetClientRequest(t));
+    private static final Function1<ActorRef, ?> GET_CLIENT_FACTORY = ExplicitAsk.toScala(GetClientRequest::new);
 
     private final ActorContext actorContext;
 
 
     private final ActorContext actorContext;
 
index b22829370336e26f0da06c9c344ba1fba9c8add0..00b29e4c35e73ade56c3453f963375e4c20edd23 100644 (file)
@@ -87,9 +87,8 @@ abstract class LocalProxyTransaction extends AbstractProxyTransaction {
 
     @Override
     final void doAbort() {
 
     @Override
     final void doAbort() {
-        sendAbort(new AbortLocalTransactionRequest(identifier, localActor()), response -> {
-            LOG.debug("Transaction {} abort completed with {}", identifier, response);
-        });
+        sendAbort(new AbortLocalTransactionRequest(identifier, localActor()),
+            response -> LOG.debug("Transaction {} abort completed with {}", identifier, response));
     }
 
     @Override
     }
 
     @Override
index 6ca58888d3a830e772dc07fd95988bac0ef42e1e..f6dee7ce7b32705a333fbf7f5cc23f5eb410a5ef 100644 (file)
@@ -156,16 +156,14 @@ abstract class AbstractFrontendHistory implements Identifiable<LocalHistoryIdent
 
     void destroy(final long sequence, final RequestEnvelope envelope, final long now) {
         LOG.debug("{}: closing history {}", persistenceId(), getIdentifier());
 
     void destroy(final long sequence, final RequestEnvelope envelope, final long now) {
         LOG.debug("{}: closing history {}", persistenceId(), getIdentifier());
-        tree.closeTransactionChain(getIdentifier(), () -> {
-            envelope.sendSuccess(new LocalHistorySuccess(getIdentifier(), sequence), readTime() - now);
-        });
+        tree.closeTransactionChain(getIdentifier(),
+            () -> envelope.sendSuccess(new LocalHistorySuccess(getIdentifier(), sequence), readTime() - now));
     }
 
     void purge(final long sequence, final RequestEnvelope envelope, final long now) {
         LOG.debug("{}: purging history {}", persistenceId(), getIdentifier());
     }
 
     void purge(final long sequence, final RequestEnvelope envelope, final long now) {
         LOG.debug("{}: purging history {}", persistenceId(), getIdentifier());
-        tree.purgeTransactionChain(getIdentifier(), () -> {
-            envelope.sendSuccess(new LocalHistorySuccess(getIdentifier(), sequence), readTime() - now);
-        });
+        tree.purgeTransactionChain(getIdentifier(),
+            () -> envelope.sendSuccess(new LocalHistorySuccess(getIdentifier(), sequence), readTime() - now));
     }
 
     private FrontendTransaction createTransaction(final TransactionRequest<?> request, final TransactionIdentifier id)
     }
 
     private FrontendTransaction createTransaction(final TransactionRequest<?> request, final TransactionIdentifier id)
index 338ae645345bc8b4e3237965260e67590ad811da..e8c0567e0610968ceba4eaba50e6045e625ef6f5 100644 (file)
@@ -224,7 +224,7 @@ class CompositeDataTreeCohort {
 
         final Iterable<Object> results;
         try {
 
         final Iterable<Object> results;
         try {
-            results = Await.result(Futures.sequence(Lists.transform(futures, e -> e.getValue()),
+            results = Await.result(Futures.sequence(Lists.transform(futures, Entry::getValue),
                 ExecutionContexts.global()), timeout.duration());
         } catch (TimeoutException e) {
             successfulFromPrevious = null;
                 ExecutionContexts.global()), timeout.duration());
         } catch (TimeoutException e) {
             successfulFromPrevious = null;
index 1e0d1279e3e749b9728a3d8cdfc1d61ec59facbc..5bafef8a854af9bfed716bdc4a220b8c53998fe5 100644 (file)
@@ -187,7 +187,7 @@ final class RemoteTransactionContextSupport {
 
                 getActorContext().getActorSystem().scheduler().scheduleOnce(
                     FiniteDuration.create(scheduleInterval, TimeUnit.MILLISECONDS),
 
                 getActorContext().getActorSystem().scheduler().scheduleOnce(
                     FiniteDuration.create(scheduleInterval, TimeUnit.MILLISECONDS),
-                    () -> tryFindPrimaryShard(), getActorContext().getClientDispatcher());
+                        this::tryFindPrimaryShard, getActorContext().getClientDispatcher());
                 return;
             }
         }
                 return;
             }
         }
index d2b4dd3077d60b80d1112534246e7c0cded97c99..84a58d95943bcd3405db83b5199c08a1acfc0d5b 100644 (file)
@@ -119,8 +119,8 @@ class EntityOwnershipListenerSupport extends EntityOwnershipChangePublisher {
         try {
             Collection<DOMEntityOwnershipListener> listeners = entityTypeListenerMap.get(entity.getType());
             if (!listeners.isEmpty()) {
         try {
             Collection<DOMEntityOwnershipListener> listeners = entityTypeListenerMap.get(entity.getType());
             if (!listeners.isEmpty()) {
-                notifyListeners(entity, wasOwner, isOwner, hasOwner, listeners.stream().map(
-                    listener -> listenerActorMap.get(listener)).collect(Collectors.toList()));
+                notifyListeners(entity, wasOwner, isOwner, hasOwner,
+                        listeners.stream().map(listenerActorMap::get).collect(Collectors.toList()));
             }
         } finally {
             listenerLock.readLock().unlock();
             }
         } finally {
             listenerLock.readLock().unlock();
index 671fbb89652b42ed1b34a2623346715ef6d559c1..224ca0b3d0b19ad41209d419351c1faa2d080940 100644 (file)
@@ -246,12 +246,12 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
         final CompletableFuture<Void> combinedFuture = CompletableFuture.allOf(
                 futures.toArray(new CompletableFuture[futures.size()]));
 
         final CompletableFuture<Void> combinedFuture = CompletableFuture.allOf(
                 futures.toArray(new CompletableFuture[futures.size()]));
 
-        combinedFuture.thenRun(() -> {
-            sender.tell(new Status.Success(null), noSender());
-        }).exceptionally(throwable -> {
-            sender.tell(new Status.Failure(throwable), self());
-            return null;
-        });
+        combinedFuture
+                .thenRun(() -> sender.tell(new Success(null), noSender()))
+                .exceptionally(throwable -> {
+                    sender.tell(new Status.Failure(throwable), self());
+                    return null;
+                });
     }
 
     private void onNotifyProducerCreated(final NotifyProducerCreated message) {
     }
 
     private void onNotifyProducerCreated(final NotifyProducerCreated message) {
index 8aca70df01bb3cdf38149d18693e91d7647ee6a2..bef18ffe200216502fb7fc42fe10de657b6f7799 100644 (file)
@@ -116,14 +116,11 @@ public class ConcurrentDOMDataBrokerTest {
         Answer<ListenableFuture<Boolean>> asyncCanCommit = invocation -> {
             final SettableFuture<Boolean> future = SettableFuture.create();
             if (doAsync) {
         Answer<ListenableFuture<Boolean>> asyncCanCommit = invocation -> {
             final SettableFuture<Boolean> future = SettableFuture.create();
             if (doAsync) {
-                new Thread() {
-                    @Override
-                    public void run() {
-                        Uninterruptibles.awaitUninterruptibly(asyncCanCommitContinue,
-                                10, TimeUnit.SECONDS);
-                        future.set(true);
-                    }
-                }.start();
+                new Thread(() -> {
+                    Uninterruptibles.awaitUninterruptibly(asyncCanCommitContinue,
+                            10, TimeUnit.SECONDS);
+                    future.set(true);
+                }).start();
             } else {
                 future.set(true);
             }
             } else {
                 future.set(true);
             }
index 3a676586eb4d6afb4f002adb48c5ad86ac2d5e71..4e29d4d5bb47ab1f4e3687303e2a92e74d697305 100644 (file)
@@ -206,9 +206,8 @@ public abstract class AbstractShardTest extends AbstractActorTest {
             return null;
         }).when(mock).validate(any(DataTreeModification.class));
 
             return null;
         }).when(mock).validate(any(DataTreeModification.class));
 
-        doAnswer(invocation -> {
-            return actual.prepare(invocation.getArgumentAt(0, DataTreeModification.class));
-        }).when(mock).prepare(any(DataTreeModification.class));
+        doAnswer(invocation -> actual.prepare(invocation.getArgumentAt(0, DataTreeModification.class))).when(
+                mock).prepare(any(DataTreeModification.class));
 
         doAnswer(invocation -> {
             actual.commit(invocation.getArgumentAt(0, DataTreeCandidate.class));
 
         doAnswer(invocation -> {
             actual.commit(invocation.getArgumentAt(0, DataTreeCandidate.class));
@@ -220,13 +219,9 @@ public abstract class AbstractShardTest extends AbstractActorTest {
             return null;
         }).when(mock).setSchemaContext(any(SchemaContext.class));
 
             return null;
         }).when(mock).setSchemaContext(any(SchemaContext.class));
 
-        doAnswer(invocation -> {
-            return actual.takeSnapshot();
-        }).when(mock).takeSnapshot();
+        doAnswer(invocation -> actual.takeSnapshot()).when(mock).takeSnapshot();
 
 
-        doAnswer(invocation -> {
-            return actual.getRootPath();
-        }).when(mock).getRootPath();
+        doAnswer(invocation -> actual.getRootPath()).when(mock).getRootPath();
 
         return mock;
     }
 
         return mock;
     }
index 64f088f1369d6fac8b1aab9c6a601ee64982d586..fdebed167e88f93ce86410d85d39b37dc219ac34 100644 (file)
@@ -81,13 +81,7 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest {
 
                 final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 final DataChangeScope scope = AsyncDataBroker.DataChangeScope.ONE;
 
                 final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 final DataChangeScope scope = AsyncDataBroker.DataChangeScope.ONE;
-                new Thread() {
-                    @Override
-                    public void run() {
-                        proxy.init(path, scope);
-                    }
-
-                }.start();
+                new Thread(() -> proxy.init(path, scope)).start();
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
@@ -141,13 +135,7 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest {
 
                 final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 final DataChangeScope scope = AsyncDataBroker.DataChangeScope.ONE;
 
                 final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 final DataChangeScope scope = AsyncDataBroker.DataChangeScope.ONE;
-                new Thread() {
-                    @Override
-                    public void run() {
-                        proxy.init(path, scope);
-                    }
-
-                }.start();
+                new Thread(() -> proxy.init(path, scope)).start();
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
@@ -198,13 +186,7 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest {
 
                 final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 final DataChangeScope scope = AsyncDataBroker.DataChangeScope.ONE;
 
                 final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 final DataChangeScope scope = AsyncDataBroker.DataChangeScope.ONE;
-                new Thread() {
-                    @Override
-                    public void run() {
-                        proxy.init(path, scope);
-                    }
-
-                }.start();
+                new Thread(() -> proxy.init(path, scope)).start();
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
@@ -231,13 +213,7 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest {
 
                 final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 final DataChangeScope scope = AsyncDataBroker.DataChangeScope.ONE;
 
                 final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 final DataChangeScope scope = AsyncDataBroker.DataChangeScope.ONE;
-                new Thread() {
-                    @Override
-                    public void run() {
-                        proxy.init(path, scope);
-                    }
-
-                }.start();
+                new Thread(() -> proxy.init(path, scope)).start();
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
index 927f9297979453589d2e2fa59c96ce82910df3c1..c66c3cd0aeb264291fad8aeddb3e3da7b68f1aad 100644 (file)
@@ -60,13 +60,7 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
                 final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(
                         actorContext, mockListener, path);
 
                 final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(
                         actorContext, mockListener, path);
 
-                new Thread() {
-                    @Override
-                    public void run() {
-                        proxy.init("shard-1");
-                    }
-
-                }.start();
+                new Thread(() -> proxy.init("shard-1")).start();
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
@@ -119,13 +113,7 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
                 final DataTreeChangeListenerProxy<ClusteredDOMDataTreeChangeListener> proxy =
                         new DataTreeChangeListenerProxy<>(actorContext, mockClusteredListener, path);
 
                 final DataTreeChangeListenerProxy<ClusteredDOMDataTreeChangeListener> proxy =
                         new DataTreeChangeListenerProxy<>(actorContext, mockClusteredListener, path);
 
-                new Thread() {
-                    @Override
-                    public void run() {
-                        proxy.init("shard-1");
-                    }
-
-                }.start();
+                new Thread(() -> proxy.init("shard-1")).start();
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
@@ -154,13 +142,7 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
                 final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(
                         actorContext, mockListener, path);
 
                 final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(
                         actorContext, mockListener, path);
 
-                new Thread() {
-                    @Override
-                    public void run() {
-                        proxy.init("shard-1");
-                    }
-
-                }.start();
+                new Thread(() -> proxy.init("shard-1")).start();
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
@@ -186,13 +168,7 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
                 final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(
                         actorContext, mockListener, path);
 
                 final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(
                         actorContext, mockListener, path);
 
-                new Thread() {
-                    @Override
-                    public void run() {
-                        proxy.init("shard-1");
-                    }
-
-                }.start();
+                new Thread(() -> proxy.init("shard-1")).start();
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
index 2cd2b29c8d3e38d65f241d164f93570f560a4e9a..7773556eca85f2db454cc6336eec16728a39238d 100644 (file)
@@ -363,28 +363,25 @@ public class DistributedDataStoreIntegrationTest {
                     final AtomicReference<DOMStoreThreePhaseCommitCohort> txCohort = new AtomicReference<>();
                     final AtomicReference<Exception> caughtEx = new AtomicReference<>();
                     final CountDownLatch txReady = new CountDownLatch(1);
                     final AtomicReference<DOMStoreThreePhaseCommitCohort> txCohort = new AtomicReference<>();
                     final AtomicReference<Exception> caughtEx = new AtomicReference<>();
                     final CountDownLatch txReady = new CountDownLatch(1);
-                    final Thread txThread = new Thread() {
-                        @Override
-                        public void run() {
-                            try {
-                                writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+                    final Thread txThread = new Thread(() -> {
+                        try {
+                            writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
 
 
-                                writeTx.merge(TestModel.OUTER_LIST_PATH,
-                                        ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
+                            writeTx.merge(TestModel.OUTER_LIST_PATH,
+                                    ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
 
 
-                                writeTx.write(listEntryPath,
-                                        ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1));
+                            writeTx.write(listEntryPath,
+                                    ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1));
 
 
-                                writeTx.delete(listEntryPath);
+                            writeTx.delete(listEntryPath);
 
 
-                                txCohort.set(writeTx.ready());
-                            } catch (Exception e) {
-                                caughtEx.set(e);
-                            } finally {
-                                txReady.countDown();
-                            }
+                            txCohort.set(writeTx.ready());
+                        } catch (Exception e) {
+                            caughtEx.set(e);
+                        } finally {
+                            txReady.countDown();
                         }
                         }
-                    };
+                    });
 
                     txThread.start();
 
 
                     txThread.start();
 
@@ -460,23 +457,20 @@ public class DistributedDataStoreIntegrationTest {
                             txReadFuture = new AtomicReference<>();
                     final AtomicReference<Exception> caughtEx = new AtomicReference<>();
                     final CountDownLatch txReadsDone = new CountDownLatch(1);
                             txReadFuture = new AtomicReference<>();
                     final AtomicReference<Exception> caughtEx = new AtomicReference<>();
                     final CountDownLatch txReadsDone = new CountDownLatch(1);
-                    final Thread txThread = new Thread() {
-                        @Override
-                        public void run() {
-                            try {
-                                readWriteTx.write(TestModel.TEST_PATH,
-                                        ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+                    final Thread txThread = new Thread(() -> {
+                        try {
+                            readWriteTx.write(TestModel.TEST_PATH,
+                                    ImmutableNodes.containerNode(TestModel.TEST_QNAME));
 
 
-                                txExistsFuture.set(readWriteTx.exists(TestModel.TEST_PATH));
+                            txExistsFuture.set(readWriteTx.exists(TestModel.TEST_PATH));
 
 
-                                txReadFuture.set(readWriteTx.read(TestModel.TEST_PATH));
-                            } catch (Exception e) {
-                                caughtEx.set(e);
-                            } finally {
-                                txReadsDone.countDown();
-                            }
+                            txReadFuture.set(readWriteTx.read(TestModel.TEST_PATH));
+                        } catch (Exception e) {
+                            caughtEx.set(e);
+                        } finally {
+                            txReadsDone.countDown();
                         }
                         }
-                    };
+                    });
 
                     txThread.start();
 
 
                     txThread.start();
 
index e2dc8143e5e16a72a0c2f9ba3d47cc96d915ff78..0e1dd4448ec59d85c4cc096e7b3d5650a6b7fc4c 100644 (file)
@@ -127,33 +127,25 @@ public final class ShardDataTreeMocking {
 
     @SuppressWarnings("unchecked")
     public static ShardDataTreeCohort failedCanCommit(final ShardDataTreeCohort mock) {
 
     @SuppressWarnings("unchecked")
     public static ShardDataTreeCohort failedCanCommit(final ShardDataTreeCohort mock) {
-        doAnswer(invocation -> {
-            return invokeFailure(invocation);
-        }).when(mock).canCommit(any(FutureCallback.class));
+        doAnswer(ShardDataTreeMocking::invokeFailure).when(mock).canCommit(any(FutureCallback.class));
         return mock;
     }
 
     @SuppressWarnings("unchecked")
     public static ShardDataTreeCohort failedPreCommit(final ShardDataTreeCohort mock) {
         return mock;
     }
 
     @SuppressWarnings("unchecked")
     public static ShardDataTreeCohort failedPreCommit(final ShardDataTreeCohort mock) {
-        doAnswer(invocation -> {
-            return invokeFailure(invocation);
-        }).when(mock).preCommit(any(FutureCallback.class));
+        doAnswer(ShardDataTreeMocking::invokeFailure).when(mock).preCommit(any(FutureCallback.class));
         return mock;
     }
 
     @SuppressWarnings("unchecked")
     public static ShardDataTreeCohort failedCommit(final ShardDataTreeCohort mock) {
         return mock;
     }
 
     @SuppressWarnings("unchecked")
     public static ShardDataTreeCohort failedCommit(final ShardDataTreeCohort mock) {
-        doAnswer(invocation -> {
-            return invokeFailure(invocation);
-        }).when(mock).commit(any(FutureCallback.class));
+        doAnswer(ShardDataTreeMocking::invokeFailure).when(mock).commit(any(FutureCallback.class));
         return mock;
     }
 
     @SuppressWarnings("unchecked")
     public static ShardDataTreeCohort successfulCanCommit(final ShardDataTreeCohort mock) {
         return mock;
     }
 
     @SuppressWarnings("unchecked")
     public static ShardDataTreeCohort successfulCanCommit(final ShardDataTreeCohort mock) {
-        doAnswer(invocation -> {
-            return invokeSuccess(invocation, null);
-        }).when(mock).canCommit(any(FutureCallback.class));
+        doAnswer(invocation -> invokeSuccess(invocation, null)).when(mock).canCommit(any(FutureCallback.class));
 
         return mock;
     }
 
         return mock;
     }
@@ -165,9 +157,7 @@ public final class ShardDataTreeMocking {
     @SuppressWarnings("unchecked")
     public static ShardDataTreeCohort successfulPreCommit(final ShardDataTreeCohort mock,
             final DataTreeCandidate candidate) {
     @SuppressWarnings("unchecked")
     public static ShardDataTreeCohort successfulPreCommit(final ShardDataTreeCohort mock,
             final DataTreeCandidate candidate) {
-        doAnswer(invocation -> {
-            return invokeSuccess(invocation, candidate);
-        }).when(mock).preCommit(any(FutureCallback.class));
+        doAnswer(invocation -> invokeSuccess(invocation, candidate)).when(mock).preCommit(any(FutureCallback.class));
 
         return mock;
     }
 
         return mock;
     }
@@ -178,9 +168,7 @@ public final class ShardDataTreeMocking {
 
     @SuppressWarnings("unchecked")
     public static ShardDataTreeCohort successfulCommit(final ShardDataTreeCohort mock, final UnsignedLong index) {
 
     @SuppressWarnings("unchecked")
     public static ShardDataTreeCohort successfulCommit(final ShardDataTreeCohort mock, final UnsignedLong index) {
-        doAnswer(invocation -> {
-            return invokeSuccess(invocation, index);
-        }).when(mock).commit(any(FutureCallback.class));
+        doAnswer(invocation -> invokeSuccess(invocation, index)).when(mock).commit(any(FutureCallback.class));
 
         return mock;
     }
 
         return mock;
     }
index ce2a43f015bbcb5ea67f791514f0eef02e7c19ae..f566ba8d07181b6497f4ec5893d6a0c9c479313a 100644 (file)
@@ -198,14 +198,11 @@ public class ShardTest extends AbstractShardTest {
                             // original ElectionTimeout message to proceed with the election.
                             firstElectionTimeout = false;
                             final ActorRef self = getSelf();
                             // original ElectionTimeout message to proceed with the election.
                             firstElectionTimeout = false;
                             final ActorRef self = getSelf();
-                            new Thread() {
-                                @Override
-                                public void run() {
-                                    Uninterruptibles.awaitUninterruptibly(
-                                            onChangeListenerRegistered, 5, TimeUnit.SECONDS);
-                                    self.tell(message, self);
-                                }
-                            }.start();
+                            new Thread(() -> {
+                                Uninterruptibles.awaitUninterruptibly(
+                                        onChangeListenerRegistered, 5, TimeUnit.SECONDS);
+                                self.tell(message, self);
+                            }).start();
 
                             onFirstElectionTimeout.countDown();
                         } else {
 
                             onFirstElectionTimeout.countDown();
                         } else {
@@ -307,14 +304,11 @@ public class ShardTest extends AbstractShardTest {
                         if (message instanceof ElectionTimeout && firstElectionTimeout) {
                             firstElectionTimeout = false;
                             final ActorRef self = getSelf();
                         if (message instanceof ElectionTimeout && firstElectionTimeout) {
                             firstElectionTimeout = false;
                             final ActorRef self = getSelf();
-                            new Thread() {
-                                @Override
-                                public void run() {
-                                    Uninterruptibles.awaitUninterruptibly(
-                                            onChangeListenerRegistered, 5, TimeUnit.SECONDS);
-                                    self.tell(message, self);
-                                }
-                            }.start();
+                            new Thread(() -> {
+                                Uninterruptibles.awaitUninterruptibly(
+                                        onChangeListenerRegistered, 5, TimeUnit.SECONDS);
+                                self.tell(message, self);
+                            }).start();
 
                             onFirstElectionTimeout.countDown();
                         } else {
 
                             onFirstElectionTimeout.countDown();
                         } else {
index 78266df646e8ca47daa83a29900ae3f0263ef7dd..9fd0849bf16199682fbc3c3bc5ea631ba5884751 100644 (file)
@@ -152,18 +152,15 @@ public class TransactionChainProxyTest extends AbstractTransactionProxyTest {
 
             final AtomicReference<Exception> caughtEx = new AtomicReference<>();
             final CountDownLatch write2Complete = new CountDownLatch(1);
 
             final AtomicReference<Exception> caughtEx = new AtomicReference<>();
             final CountDownLatch write2Complete = new CountDownLatch(1);
-            new Thread() {
-                @Override
-                public void run() {
-                    try {
-                        writeTx2.write(TestModel.OUTER_LIST_PATH, writeNode2);
-                    } catch (Exception e) {
-                        caughtEx.set(e);
-                    } finally {
-                        write2Complete.countDown();
-                    }
+            new Thread(() -> {
+                try {
+                    writeTx2.write(TestModel.OUTER_LIST_PATH, writeNode2);
+                } catch (Exception e) {
+                    caughtEx.set(e);
+                } finally {
+                    write2Complete.countDown();
                 }
                 }
-            }.start();
+            }).start();
 
             assertEquals("Tx 2 write should've completed", true, write2Complete.await(5, TimeUnit.SECONDS));
 
 
             assertEquals("Tx 2 write should've completed", true, write2Complete.await(5, TimeUnit.SECONDS));
 
@@ -224,18 +221,15 @@ public class TransactionChainProxyTest extends AbstractTransactionProxyTest {
 
             final AtomicReference<Exception> caughtEx = new AtomicReference<>();
             final CountDownLatch write2Complete = new CountDownLatch(1);
 
             final AtomicReference<Exception> caughtEx = new AtomicReference<>();
             final CountDownLatch write2Complete = new CountDownLatch(1);
-            new Thread() {
-                @Override
-                public void run() {
-                    try {
-                        writeTx2.write(TestModel.OUTER_LIST_PATH, writeNode2);
-                    } catch (Exception e) {
-                        caughtEx.set(e);
-                    } finally {
-                        write2Complete.countDown();
-                    }
+            new Thread(() -> {
+                try {
+                    writeTx2.write(TestModel.OUTER_LIST_PATH, writeNode2);
+                } catch (Exception e) {
+                    caughtEx.set(e);
+                } finally {
+                    write2Complete.countDown();
                 }
                 }
-            }.start();
+            }).start();
 
             assertEquals("Tx 2 write should've completed", true, write2Complete.await(5, TimeUnit.SECONDS));
 
 
             assertEquals("Tx 2 write should've completed", true, write2Complete.await(5, TimeUnit.SECONDS));
 
index 6e37a975ed6aafaa84849a9b1b0289d8f2d60065..f40374b924f68ab84d571a6ef87194d88f01edb1 100644 (file)
@@ -1328,7 +1328,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
         assertEquals("getType", shardMrgIDSuffix, datastoreSnapshot.getType());
         assertNull("Expected null ShardManagerSnapshot", datastoreSnapshot.getShardManagerSnapshot());
 
         assertEquals("getType", shardMrgIDSuffix, datastoreSnapshot.getType());
         assertNull("Expected null ShardManagerSnapshot", datastoreSnapshot.getShardManagerSnapshot());
 
-        Function<ShardSnapshot, String> shardNameTransformer = s -> s.getName();
+        Function<ShardSnapshot, String> shardNameTransformer = ShardSnapshot::getName;
 
         assertEquals("Shard names", Sets.newHashSet("shard1", "shard2"), Sets.newHashSet(
                 Lists.transform(datastoreSnapshot.getShardSnapshots(), shardNameTransformer)));
 
         assertEquals("Shard names", Sets.newHashSet("shard1", "shard2"), Sets.newHashSet(
                 Lists.transform(datastoreSnapshot.getShardSnapshots(), shardNameTransformer)));