Narrow down SuppressFBWarnings in ModelProcessingPhase 60/94760/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 25 Nov 2020 09:14:21 +0000 (10:14 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 23 Jan 2021 07:27:11 +0000 (08:27 +0100)
We are suppressing a single null assignment, make sure we minimize
the scope of suppression.

Change-Id: Ie7b62be11964df2553268eb9f49cca1e2c8538b9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f271abeab81db4ae7808d5824b16dcf289023fc1)

yang/yang-parser-spi/src/main/java/module-info.java
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/ModelProcessingPhase.java

index b28ab1b6f15f3973b026cd02fcccdb4117d0954f..a7a6b2d74db3f4ac9b16ae9a388142bd60c88171 100644 (file)
@@ -15,5 +15,6 @@ module org.opendaylight.yangtools.yang.parser.spi {
     requires org.slf4j;
 
     // Annotations
+    requires static com.github.spotbugs.annotations;
     requires static org.eclipse.jdt.annotation;
 }
index f47b1ef06d524316549fae2c4c8b2571283dd557..196f3ee86f0380e810a79a2ef9a4929c42e394e7 100644 (file)
@@ -7,14 +7,15 @@
  */
 package org.opendaylight.yangtools.yang.parser.spi.meta;
 
+import static java.util.Objects.requireNonNull;
+
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 
 @NonNullByDefault
-@SuppressFBWarnings("NP_NULL_PARAM_DEREF_NONVIRTUAL")
 public enum ModelProcessingPhase {
-    INIT(null),
+    INIT(),
 
     /**
      * Preliminary cross-source relationship resolution phase which collects available module names and module
@@ -41,8 +42,14 @@ public enum ModelProcessingPhase {
 
     private final @Nullable ModelProcessingPhase previousPhase;
 
-    ModelProcessingPhase(final @Nullable ModelProcessingPhase previous) {
-        this.previousPhase = previous;
+    @SuppressFBWarnings(value = "NP_STORE_INTO_NONNULL_FIELD",
+        justification = "https://github.com/spotbugs/spotbugs/issues/743")
+    ModelProcessingPhase() {
+        previousPhase = null;
+    }
+
+    ModelProcessingPhase(final ModelProcessingPhase previousPhase) {
+        this.previousPhase = requireNonNull(previousPhase);
     }
 
     /**