Cleanup java.util.Optional references 10/80410/2
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 20 Feb 2019 10:46:03 +0000 (11:46 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 20 Feb 2019 12:41:31 +0000 (13:41 +0100)
As a byproduct of gradual migration, we have a few places where
we use FQCN to reference java.util.Optional eventhough it is among
imports. Fix that.

Change-Id: Ibede76ffc614c02dbc5e29e78e6c421abcd81ec9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 files changed:
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomRead.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractProxyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/RemoteProxyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendReadOnlyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendReadWriteTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipService.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/ClientSnapshotTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/ClientTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeTest.java

index 0800585..3081289 100644 (file)
@@ -62,7 +62,7 @@ public class SimpletxDomRead extends DatastoreAbstractWriter {
         try (DOMDataTreeReadTransaction tx = domDataBroker.newReadOnlyTransaction()) {
             for (int l = 0; l < outerListElem; l++) {
                 YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, olId, l));
-                FluentFuture<java.util.Optional<NormalizedNode<?, ?>>> submitFuture = tx.read(dsType, yid);
+                FluentFuture<Optional<NormalizedNode<?, ?>>> submitFuture = tx.read(dsType, yid);
                 try {
                     Optional<NormalizedNode<?,?>> optionalDataObject = submitFuture.get();
                     if (optionalDataObject != null && optionalDataObject.isPresent()) {
index dab0c9f..f8cb9e0 100644 (file)
@@ -350,7 +350,7 @@ abstract class AbstractProxyTransaction implements Identifiable<TransactionIdent
         // At this point the successor has completed transition and is possibly visible by the user thread, which is
         // still stuck here. The successor has not seen final part of our state, nor the fact it is sealed.
         // Propagate state and seal the successor.
-        final java.util.Optional<ModifyTransactionRequest> optState = flushState();
+        final Optional<ModifyTransactionRequest> optState = flushState();
         if (optState.isPresent()) {
             forwardToSuccessor(successor, optState.get(), null);
         }
@@ -722,7 +722,7 @@ abstract class AbstractProxyTransaction implements Identifiable<TransactionIdent
         if (SEALED.equals(prevState)) {
             LOG.debug("Proxy {} reconnected while being sealed, propagating state to successor {}", this, successor);
             final long enqueuedTicks = parent.currentTime();
-            final java.util.Optional<ModifyTransactionRequest> optState = flushState();
+            final Optional<ModifyTransactionRequest> optState = flushState();
             if (optState.isPresent()) {
                 successor.handleReplayedRemoteRequest(optState.get(), null, enqueuedTicks);
             }
@@ -801,7 +801,7 @@ abstract class AbstractProxyTransaction implements Identifiable<TransactionIdent
     abstract FluentFuture<Optional<NormalizedNode<?, ?>>> doRead(YangInstanceIdentifier path);
 
     @GuardedBy("this")
-    abstract java.util.Optional<ModifyTransactionRequest> flushState();
+    abstract Optional<ModifyTransactionRequest> flushState();
 
     abstract TransactionRequest<?> abortRequest();
 
index 284be4a..46e1924 100644 (file)
@@ -284,14 +284,14 @@ final class RemoteProxyTransaction extends AbstractProxyTransaction {
     }
 
     @Override
-    java.util.Optional<ModifyTransactionRequest> flushState() {
+    Optional<ModifyTransactionRequest> flushState() {
         if (!builderBusy) {
-            return java.util.Optional.empty();
+            return Optional.empty();
         }
 
         final ModifyTransactionRequest request = builder.build();
         builderBusy = false;
-        return java.util.Optional.of(request);
+        return Optional.of(request);
     }
 
     @Override
@@ -342,7 +342,7 @@ final class RemoteProxyTransaction extends AbstractProxyTransaction {
             final ModifyTransactionRequest req) {
         req.getModifications().forEach(this::appendModification);
 
-        final java.util.Optional<PersistenceProtocol> maybeProto = req.getPersistenceProtocol();
+        final Optional<PersistenceProtocol> maybeProto = req.getPersistenceProtocol();
         if (maybeProto.isPresent()) {
             // Persistence protocol implies we are sealed, propagate the marker, but hold off doing other actions
             // until we know what we are going to do.
@@ -483,7 +483,7 @@ final class RemoteProxyTransaction extends AbstractProxyTransaction {
             final ModifyTransactionRequest req) {
         req.getModifications().forEach(this::appendModification);
 
-        final java.util.Optional<PersistenceProtocol> maybeProto = req.getPersistenceProtocol();
+        final Optional<PersistenceProtocol> maybeProto = req.getPersistenceProtocol();
         if (maybeProto.isPresent()) {
             // Persistence protocol implies we are sealed, propagate the marker, but hold off doing other actions
             // until we know what we are going to do.
index 81400a2..daba580 100644 (file)
@@ -74,7 +74,7 @@ final class FrontendReadOnlyTransaction extends FrontendTransaction {
     private void handleModifyTransaction(final ModifyTransactionRequest request, final RequestEnvelope envelope,
             final long now) {
         // The only valid request here is with abort protocol
-        final java.util.Optional<PersistenceProtocol> optProto = request.getPersistenceProtocol();
+        final Optional<PersistenceProtocol> optProto = request.getPersistenceProtocol();
         Preconditions.checkArgument(optProto.isPresent(), "Commit protocol is missing in %s", request);
         Preconditions.checkArgument(optProto.get() == PersistenceProtocol.ABORT, "Unsupported commit protocol in %s",
                 request);
index e2ae16f..28ab70a 100644 (file)
@@ -509,12 +509,11 @@ final class FrontendReadWriteTransaction extends FrontendTransaction {
             throw new UnsupportedRequestException(request);
         }
 
-        final java.util.Optional<Exception> optFailure = request.getDelayedFailure();
+        final Optional<Exception> optFailure = request.getDelayedFailure();
         if (optFailure.isPresent()) {
             state = new Ready(history().createFailedCohort(getIdentifier(), sealedModification, optFailure.get()));
         } else {
-            state = new Ready(history().createReadyCohort(getIdentifier(), sealedModification,
-                    java.util.Optional.empty()));
+            state = new Ready(history().createReadyCohort(getIdentifier(), sealedModification, Optional.empty()));
         }
 
         if (request.isCoordinated()) {
@@ -562,7 +561,7 @@ final class FrontendReadWriteTransaction extends FrontendTransaction {
             final RequestEnvelope envelope, final long now) throws RequestException {
         // We need to examine the persistence protocol first to see if this is an idempotent request. If there is no
         // protocol, there is nothing for us to do.
-        final java.util.Optional<PersistenceProtocol> maybeProto = request.getPersistenceProtocol();
+        final Optional<PersistenceProtocol> maybeProto = request.getPersistenceProtocol();
         if (!maybeProto.isPresent()) {
             applyModifications(request.getModifications());
             return replyModifySuccess(request.getSequence());
@@ -608,7 +607,7 @@ final class FrontendReadWriteTransaction extends FrontendTransaction {
         }
 
         applyModifications(modifications);
-        state = new Ready(checkOpen().ready(java.util.Optional.empty()));
+        state = new Ready(checkOpen().ready(Optional.empty()));
         LOG.debug("{}: transitioned {} to ready", persistenceId(), getIdentifier());
     }
 
index b25e5da..25cb174 100644 (file)
@@ -70,10 +70,10 @@ abstract class FrontendTransaction implements Identifiable<TransactionIdentifier
         return history().persistenceId();
     }
 
-    final java.util.Optional<TransactionSuccess<?>> replaySequence(final long sequence) throws RequestException {
+    final Optional<TransactionSuccess<?>> replaySequence(final long sequence) throws RequestException {
         // Fast path check: if the requested sequence is the next request, bail early
         if (expectedSequence == sequence) {
-            return java.util.Optional.empty();
+            return Optional.empty();
         }
 
         // Check sequencing: we do not need to bother with future requests
@@ -109,7 +109,7 @@ abstract class FrontendTransaction implements Identifiable<TransactionIdentifier
         }
 
         // Not found
-        return java.util.Optional.empty();
+        return Optional.empty();
     }
 
     final void purgeSequencesUpTo(final long sequence) {
index d6d44b8..78803f2 100644 (file)
@@ -278,8 +278,7 @@ public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIde
     private AbstractThreePhaseCommitCohort<ActorSelection> createMultiCommitCohort() {
 
         final List<ThreePhaseCommitCohortProxy.CohortInfo> cohorts = new ArrayList<>(txContextWrappers.size());
-        final java.util.Optional<SortedSet<String>> shardNames =
-                java.util.Optional.of(new TreeSet<>(txContextWrappers.keySet()));
+        final Optional<SortedSet<String>> shardNames = Optional.of(new TreeSet<>(txContextWrappers.keySet()));
         for (Entry<String, TransactionContextWrapper> e : txContextWrappers.entrySet()) {
             LOG.debug("Tx {} Readying transaction for shard {}", getIdentifier(), e.getKey());
 
index 95b01fb..10988a0 100644 (file)
@@ -187,7 +187,7 @@ public class DistributedEntityOwnershipService implements DOMEntityOwnershipServ
             return Optional.empty();
         }
 
-        java.util.Optional<NormalizedNode<?, ?>> entityNode = dataTree.takeSnapshot().readNode(
+        Optional<NormalizedNode<?, ?>> entityNode = dataTree.takeSnapshot().readNode(
                 entityPath(forEntity.getType(), forEntity.getIdentifier()));
         if (!entityNode.isPresent()) {
             return Optional.empty();
@@ -195,7 +195,7 @@ public class DistributedEntityOwnershipService implements DOMEntityOwnershipServ
 
         // Check if there are any candidates, if there are none we do not really have ownership state
         final MapEntryNode entity = (MapEntryNode) entityNode.get();
-        final java.util.Optional<DataContainerChild<? extends PathArgument, ?>> optionalCandidates =
+        final Optional<DataContainerChild<? extends PathArgument, ?>> optionalCandidates =
                 entity.getChild(CANDIDATE_NODE_ID);
         final boolean hasCandidates = optionalCandidates.isPresent()
                 && ((MapNode) optionalCandidates.get()).getValue().size() > 0;
@@ -204,8 +204,7 @@ public class DistributedEntityOwnershipService implements DOMEntityOwnershipServ
         }
 
         MemberName localMemberName = context.getCurrentMemberName();
-        java.util.Optional<DataContainerChild<? extends PathArgument, ?>> ownerLeaf = entity.getChild(
-            ENTITY_OWNER_NODE_ID);
+        Optional<DataContainerChild<? extends PathArgument, ?>> ownerLeaf = entity.getChild(ENTITY_OWNER_NODE_ID);
         String owner = ownerLeaf.isPresent() ? ownerLeaf.get().getValue().toString() : null;
         boolean hasOwner = !Strings.isNullOrEmpty(owner);
         boolean isOwner = hasOwner && localMemberName.getName().equals(owner);
index 6ccd091..8e5d565 100644 (file)
@@ -28,7 +28,7 @@ public class ClientSnapshotTest extends AbstractClientHandleTest<ClientSnapshot>
     @Override
     public void setUp() throws Exception {
         super.setUp();
-        when(getDataTreeSnapshot().readNode(PATH)).thenReturn(java.util.Optional.empty());
+        when(getDataTreeSnapshot().readNode(PATH)).thenReturn(Optional.empty());
     }
 
     @Override
index a801b9c..bb8fbf1 100644 (file)
@@ -49,7 +49,7 @@ public class ClientTransactionTest extends AbstractClientHandleTest<ClientTransa
     public void setUp() throws Exception {
         super.setUp();
         when(getDataTreeSnapshot().newModification()).thenReturn(modification);
-        when(modification.readNode(PATH)).thenReturn(java.util.Optional.of(DATA));
+        when(modification.readNode(PATH)).thenReturn(Optional.of(DATA));
     }
 
     @Override
index ab9dab4..ddd43af 100644 (file)
@@ -654,8 +654,7 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest {
         new WriteModification(CarsModel.newCarPath("optima"), car1).apply(modification);
         modification.ready();
 
-        ReadyLocalTransaction readyLocal = new ReadyLocalTransaction(tx1 , modification, true,
-                java.util.Optional.empty());
+        ReadyLocalTransaction readyLocal = new ReadyLocalTransaction(tx1 , modification, true, Optional.empty());
 
         carsFollowerShard.get().tell(readyLocal, followerTestKit.getRef());
         Object resp = followerTestKit.expectMsgClass(Object.class);
@@ -674,7 +673,7 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest {
         new WriteModification(CarsModel.newCarPath("sportage"), car2).apply(modification);
         modification.ready();
 
-        readyLocal = new ReadyLocalTransaction(tx2 , modification, false, java.util.Optional.empty());
+        readyLocal = new ReadyLocalTransaction(tx2 , modification, false, Optional.empty());
 
         carsFollowerShard.get().tell(readyLocal, followerTestKit.getRef());
         resp = followerTestKit.expectMsgClass(Object.class);
@@ -724,7 +723,7 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest {
         ForwardedReadyTransaction forwardedReady = new ForwardedReadyTransaction(tx1,
                 DataStoreVersions.CURRENT_VERSION, new ReadWriteShardDataTreeTransaction(
                         Mockito.mock(ShardDataTreeTransactionParent.class), tx1, modification), true,
-                java.util.Optional.empty());
+                Optional.empty());
 
         carsFollowerShard.get().tell(forwardedReady, followerTestKit.getRef());
         Object resp = followerTestKit.expectMsgClass(Object.class);
@@ -745,7 +744,7 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest {
         forwardedReady = new ForwardedReadyTransaction(tx2,
                 DataStoreVersions.CURRENT_VERSION, new ReadWriteShardDataTreeTransaction(
                         Mockito.mock(ShardDataTreeTransactionParent.class), tx2, modification), false,
-                java.util.Optional.empty());
+                Optional.empty());
 
         carsFollowerShard.get().tell(forwardedReady, followerTestKit.getRef());
         resp = followerTestKit.expectMsgClass(Object.class);
index dd0c987..5fa0dda 100644 (file)
@@ -977,8 +977,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest {
 
         doReturn(dataTreeSnapshot).when(dataTree).takeSnapshot();
         doReturn(dataTreeModification).when(dataTreeSnapshot).newModification();
-        doReturn(java.util.Optional.of(readResponse)).when(dataTreeModification).readNode(
-            any(YangInstanceIdentifier.class));
+        doReturn(Optional.of(readResponse)).when(dataTreeModification).readNode(any(YangInstanceIdentifier.class));
 
         return dataTree;
     }
index 9a855a9..eccb99b 100644 (file)
@@ -246,7 +246,7 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest {
                 captorForSubtrees.capture());
         final List<Collection<DataTreeCandidate>> capturedValue = captorForChanges.getAllValues();
 
-        final java.util.Optional<NormalizedNode<?, ?>> dataAfter =
+        final Optional<NormalizedNode<?, ?>> dataAfter =
                 capturedValue.get(0).iterator().next().getRootNode().getDataAfter();
 
         final NormalizedNode<?,?> expected = ImmutableContainerNodeBuilder.create()

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.