Fix illegal check in CreateTransactionReply 21/75421/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 23 Aug 2018 14:02:40 +0000 (16:02 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 23 Aug 2018 14:03:43 +0000 (16:03 +0200)
The null check is wrong here, as instanceof will evaluate to a boolean,
which will always result in a non-null reference. Fix this by using
checkArgument().

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

index e8d9b19..87dd7c5 100644 (file)
@@ -5,10 +5,11 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.cluster.datastore.messages;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
@@ -26,8 +27,8 @@ public class CreateTransactionReply extends VersionedExternalizableMessage {
     public CreateTransactionReply(final String transactionPath, final TransactionIdentifier transactionId,
             final short version) {
         super(version);
-        this.transactionPath = Preconditions.checkNotNull(transactionPath);
-        this.transactionId = Preconditions.checkNotNull(transactionId);
+        this.transactionPath = requireNonNull(transactionPath);
+        this.transactionId = requireNonNull(transactionId);
     }
 
     public String getTransactionPath() {
@@ -60,7 +61,7 @@ public class CreateTransactionReply extends VersionedExternalizableMessage {
     }
 
     public static CreateTransactionReply fromSerializable(Object serializable) {
-        Preconditions.checkNotNull(serializable instanceof CreateTransactionReply);
+        checkArgument(serializable instanceof CreateTransactionReply);
         return (CreateTransactionReply)serializable;
     }
 

©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.