- final DistributedDataStore distributedDataStore = new DistributedDataStore(actorContext);
- doReturn(datastoreContext).when(actorContext).getDatastoreContext();
- doReturn(shardElectionTimeout).when(datastoreContext).getShardLeaderElectionTimeout();
- doReturn(FiniteDuration.apply(5000, TimeUnit.MILLISECONDS)).when(shardElectionTimeout).duration();
-
- Executors.newSingleThreadExecutor().submit(new Runnable() {
- @Override
- public void run() {
- Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
- distributedDataStore.getWaitTillReadyCountDownLatch().countDown();
- }
- });
+ try (final DistributedDataStore distributedDataStore = new DistributedDataStore(actorContext)) {
+ doReturn(datastoreContext).when(actorContext).getDatastoreContext();
+ doReturn(shardElectionTimeout).when(datastoreContext).getShardLeaderElectionTimeout();
+ doReturn(FiniteDuration.apply(5000, TimeUnit.MILLISECONDS)).when(shardElectionTimeout).duration();