Use simple requireNonNull() 15/95215/2
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 17 Feb 2021 22:42:02 +0000 (23:42 +0100)
committerRobert Varga <nite@hq.sk>
Thu, 18 Feb 2021 00:23:56 +0000 (00:23 +0000)
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>
yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java

index fc83c28ed34a989744d3357356fc9f4dc0f73439..a331d6b6d91619da119fcc3323aa94dee5a478a5 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;
@@ -607,8 +606,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", sourceReference());
-        checkNotNull(listener, "Statement context phase listener cannot be null at: %s", sourceReference());
+        requireNonNull(phase, "Statement context processing phase cannot be null");
+        requireNonNull(listener, "Statement context phase listener cannot be null");
 
         ModelProcessingPhase finishedPhase = completedPhase;
         while (finishedPhase != null) {