From 0fdb21f91e0e61e8ee911beb4cda9053537a0ccd Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 23 Aug 2018 16:02:40 +0200 Subject: [PATCH] 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 --- .../datastore/messages/CreateTransactionReply.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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; } -- 2.36.6