Fix FindBugs warnings in sal-clustering-commons 19/46919/4
authorTom Pantelis <tpanteli@brocade.com>
Thu, 13 Oct 2016 22:20:56 +0000 (18:20 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Tue, 25 Oct 2016 20:43:04 +0000 (16:43 -0400)
Fixed FindBugs warnings in sal-clustering-commons and enabled the maven plugin to
run and fail the build on violations.

For some reason, the plugin sometimes creates a local .fbExcludeFilterFile that
is a copy of the one in odlparent. It may be that it doesn't always clean it up
at the end. So I added it to the .gitignore

Change-Id: Id1ad5582f533bd4bfe714e54ae1e79d00a411552
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
.gitignore
opendaylight/md-sal/sal-clustering-commons/pom.xml
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/QuarantinedMonitorActor.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeGetter.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractNormalizedNodeDataOutput.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteYangTextSourceProviderImpl.java

index e5d9624..7b1cbba 100644 (file)
@@ -32,3 +32,4 @@ opendaylight/md-sal/sal-distributed-datastore/journal
 .checkstyle
 .factorypath
 maven-metadata-local.xml
+.fbExcludeFilterFile
index 097fdee..5b79bff 100644 (file)
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>config-api</artifactId>
     </dependency>
-
   </dependencies>
 
   <build>
                 <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
              </configuration>
           </plugin>
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>findbugs-maven-plugin</artifactId>
+            <configuration>
+              <failOnError>true</failOnError>
+            </configuration>
+          </plugin>
       </plugins>
   </build>
 </project>
index 9cb592a..519fcd0 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.controller.cluster.common.actor;
 
 import akka.actor.Props;
 import akka.actor.UntypedActor;
-import akka.japi.Creator;
 import akka.japi.Effect;
 import akka.remote.AssociationErrorEvent;
 import akka.remote.InvalidAssociation;
@@ -83,14 +82,6 @@ public class QuarantinedMonitorActor extends UntypedActor {
     }
 
     public static Props props(final Effect callback) {
-        return Props.create(new Creator<QuarantinedMonitorActor>() {
-            private static final long serialVersionUID = 1L;
-
-            @Override
-            public QuarantinedMonitorActor create() throws Exception {
-                return new QuarantinedMonitorActor(callback);
-            }
-        });
+        return Props.create(QuarantinedMonitorActor.class, callback);
     }
-
 }
index e1e7b9f..e2085e6 100644 (file)
@@ -25,7 +25,7 @@ public class NormalizedNodeGetter implements
     public void visitNode(int level, String parentPath, NormalizedNode<?, ?> normalizedNode) {
         String nodePath = parentPath + "/" + PathUtils.toString(normalizedNode.getIdentifier());
 
-        if (nodePath.toString().equals(path)) {
+        if (nodePath.equals(path)) {
             output = normalizedNode;
         }
     }
index 51a9c1c..706665b 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.cluster.datastore.node.utils.stream;
 
 import com.google.common.base.Preconditions;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -361,6 +362,8 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut
         }
     }
 
+    @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST",
+            justification = "The casts in the switch clauses are indirectly confirmed via the determination of 'type'.")
     @Override
     public void writePathArgument(final PathArgument pathArgument) throws IOException {
 
@@ -410,9 +413,9 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut
         if (keyValueMap != null && !keyValueMap.isEmpty()) {
             output.writeInt(keyValueMap.size());
 
-            for (QName qname : keyValueMap.keySet()) {
-                writeQName(qname);
-                writeObject(keyValueMap.get(qname));
+            for (Map.Entry<QName, Object> entry : keyValueMap.entrySet()) {
+                writeQName(entry.getKey());
+                writeObject(entry.getValue());
             }
         } else {
             output.writeInt(0);
index 882f2a8..fc49287 100644 (file)
@@ -14,6 +14,7 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import java.io.IOException;
 import java.util.Set;
+import javax.annotation.Nonnull;
 import org.opendaylight.controller.cluster.schema.provider.RemoteYangTextSourceProvider;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
@@ -53,7 +54,7 @@ public class RemoteYangTextSourceProviderImpl implements RemoteYangTextSourcePro
 
         Futures.addCallback(future, new FutureCallback<YangTextSchemaSource>() {
             @Override
-            public void onSuccess(YangTextSchemaSource result) {
+            public void onSuccess(@Nonnull YangTextSchemaSource result) {
                 try {
                     promise.success(new YangTextSchemaSourceSerializationProxy(result));
                 } catch (IOException e) {

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.