Enable spotbugs in yang-model-export 22/87322/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 22 Aug 2019 12:44:39 +0000 (14:44 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 31 Jan 2020 11:08:04 +0000 (12:08 +0100)
SpotBugs is getting confused by our use of checkArgument, not
understanding we will catch nulls. Refactor the code removing
the violation and remove enforcement override.

Change-Id: I787359c01f2761448cb4f3d33aea0baf5e642ed8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-model-export/src/main/java/org/opendaylight/yangtools/yang/model/export/ExportUtils.java

index 1baf8002fcfef50e3dbd8c33c86727443027a242..585cfeac6a93cbc6f844603de8d51b5b506adedb 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.yangtools.yang.model.export;
 
-import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Verify.verify;
 
 import java.util.Map;
@@ -59,7 +58,10 @@ final class ExportUtils {
             }
         }
 
-        checkArgument(prefix != null, "Failed to find prefix for statement %s", stmtName);
+        if (prefix == null) {
+            throw new IllegalArgumentException("Failed to find prefix for statement " + stmtName);
+        }
+
         verify(!prefix.isEmpty(), "Empty prefix for statement %s", stmtName);
         return Optional.of(prefix);
     }