Use simple requireNonNull() 22/95222/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 17 Feb 2021 22:42:02 +0000 (23:42 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 18 Feb 2021 00:53:56 +0000 (01:53 +0100)
StatementContextBase.addPhaseCompletedListener() is the heart of
inference and the checkNotNull() here is taking sourceReference().

Acquiring source reference is an indirection, which may actually
got through a forwarding chain. While we could use and if/throws,
let's just use plain requireNonNull.

JIRA: YANGTOOLS-652
Change-Id: I77d5b1dcc8b6b575d01ced0850d7081909b57964
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit cd04351669d5921088a73a275954ba78336c1a44)

yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java

index a9aa4099c3c1ac48d09962bb526a19b5a00153b2..e51b39706cd78eb36987bab7032bd947cdfae6ba 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.parser.stmt.reactor;
 
 import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
 import static com.google.common.base.Verify.verify;
 import static java.util.Objects.requireNonNull;
@@ -809,8 +808,8 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
      * @throws NullPointerException if any of the arguments is null
      */
     void addPhaseCompletedListener(final ModelProcessingPhase phase, final OnPhaseFinished listener) {
-        checkNotNull(phase, "Statement context processing phase cannot be null at: %s", getStatementSourceReference());
-        checkNotNull(listener, "Statement context phase listener cannot be null at: %s", getStatementSourceReference());
+        requireNonNull(phase, "Statement context processing phase cannot be null");
+        requireNonNull(listener, "Statement context phase listener cannot be null");
 
         ModelProcessingPhase finishedPhase = completedPhase;
         while (finishedPhase != null) {