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 e5d9624a08ce9c5ef6787cadd81206f94dce04f3..7b1cbba777f1e5caa80901aff7d84eb2083fbefc 100644 (file)
@@ -32,3 +32,4 @@ opendaylight/md-sal/sal-distributed-datastore/journal
 .checkstyle
 .factorypath
 maven-metadata-local.xml
 .checkstyle
 .factorypath
 maven-metadata-local.xml
+.fbExcludeFilterFile
index 097fdeeaf00387faf7fac3e816ae5632ab0ff233..5b79bffe88b2f5b2e0f441d57895b8636d29cb36 100644 (file)
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>config-api</artifactId>
     </dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>config-api</artifactId>
     </dependency>
-
   </dependencies>
 
   <build>
   </dependencies>
 
   <build>
                 <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
              </configuration>
           </plugin>
                 <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>
       </plugins>
   </build>
 </project>
index 9cb592a4c7713f5d533870c92af38d0e0dfdf4e6..519fcd071c64b20baa2adcb5033c8fc38fa1f08a 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.controller.cluster.common.actor;
 
 import akka.actor.Props;
 import akka.actor.UntypedActor;
 
 import akka.actor.Props;
 import akka.actor.UntypedActor;
-import akka.japi.Creator;
 import akka.japi.Effect;
 import akka.remote.AssociationErrorEvent;
 import akka.remote.InvalidAssociation;
 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) {
     }
 
     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 e1e7b9f684b625e859e3b8651104d2d0cccd62fa..e2085e6e540408abdb1c8180b2d538cfa71f733e 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());
 
     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;
         }
     }
             output = normalizedNode;
         }
     }
index 51a9c1c24eafe5ee29289f202679ce0e39730172..706665b0b8dfdf738a6c53d9699b2a5a72dda815 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.cluster.datastore.node.utils.stream;
 
 import com.google.common.base.Preconditions;
 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;
 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 {
 
     @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());
 
         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);
             }
         } else {
             output.writeInt(0);
index 882f2a84c954555f5dbf067dc3086c3132050e22..fc492872bd6eb3ca6237d9351373d5b431d3f37f 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 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;
 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
 
         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) {
                 try {
                     promise.success(new YangTextSchemaSourceSerializationProxy(result));
                 } catch (IOException e) {