From: Robert Varga Date: Thu, 23 Aug 2018 14:02:40 +0000 (+0200) Subject: Fix illegal check in CreateTransactionReply X-Git-Tag: release/neon~98 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=0fdb21f91e0e61e8ee911beb4cda9053537a0ccd Fix illegal check in CreateTransactionReply 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 --- diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionReply.java index e8d9b19994..87dd7c57fb 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionReply.java @@ -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; }