Clean up AbstractTransactionContextFactory 83/98383/3
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 10 Nov 2021 09:50:50 +0000 (10:50 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 10 Nov 2021 10:14:40 +0000 (11:14 +0100)
Add a few @NonNull annotations and eliminate two else blocks.

Change-Id: Ide21c363f349af7b24fb4835b859a224357586c8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContextFactory.java

index 29b52f7..6941d19 100644 (file)
@@ -41,8 +41,8 @@ abstract class AbstractTransactionContextFactory<F extends LocalTransactionFacto
             AtomicLongFieldUpdater.newUpdater(AbstractTransactionContextFactory.class, "nextTx");
 
     private final ConcurrentMap<String, F> knownLocal = new ConcurrentHashMap<>();
-    private final LocalHistoryIdentifier historyId;
-    private final ActorUtils actorUtils;
+    private final @NonNull LocalHistoryIdentifier historyId;
+    private final @NonNull ActorUtils actorUtils;
 
     // Used via TX_COUNTER_UPDATER
     @SuppressWarnings("unused")
@@ -94,14 +94,14 @@ abstract class AbstractTransactionContextFactory<F extends LocalTransactionFacto
                         parent.getIdentifier());
                 return new DirectTransactionContextWrapper(parent.getIdentifier(), actorUtils, shardName,
                         localContext);
-            } else {
-                LOG.debug("Tx {}: Local transaction context creation failed, using DelayedTransactionWrapper",
-                        parent.getIdentifier());
-                final RemoteTransactionContextSupport remote = new RemoteTransactionContextSupport(
-                        transactionContextWrapper, parent, shardName);
-                remote.setPrimaryShard(primaryShardInfo);
-                return transactionContextWrapper;
             }
+
+            LOG.debug("Tx {}: Local transaction context creation failed, using DelayedTransactionWrapper",
+                parent.getIdentifier());
+            final RemoteTransactionContextSupport remote = new RemoteTransactionContextSupport(
+                transactionContextWrapper, parent, shardName);
+            remote.setPrimaryShard(primaryShardInfo);
+            return transactionContextWrapper;
         } finally {
             onTransactionContextCreated(parent.getIdentifier());
         }
@@ -148,12 +148,10 @@ abstract class AbstractTransactionContextFactory<F extends LocalTransactionFacto
         if (findPrimaryFuture.isCompleted()) {
             final Try<PrimaryShardInfo> maybe = findPrimaryFuture.value().get();
             if (maybe.isSuccess()) {
-                return maybeCreateDirectTransactionContextWrapper(maybe.get(), parent, shardName,
-                        contextWrapper);
-            } else {
-                onFindPrimaryShardFailure(maybe.failed().get(), parent, shardName,
-                        contextWrapper);
+                return maybeCreateDirectTransactionContextWrapper(maybe.get(), parent, shardName, contextWrapper);
             }
+
+            onFindPrimaryShardFailure(maybe.failed().get(), parent, shardName, contextWrapper);
         } else {
             findPrimaryFuture.onComplete(result -> {
                 if (result.isSuccess()) {