Fix FindBugs warnings in cds-access-api and enable enforcement 73/47473/4
authorTom Pantelis <tpanteli@brocade.com>
Tue, 25 Oct 2016 05:41:17 +0000 (01:41 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Tue, 1 Nov 2016 16:53:47 +0000 (16:53 +0000)
Several warnings are suppressed with justification provided.

Change-Id: I39b860013677d045bb8e8dbd722c9b41406285ac
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/cds-access-api/pom.xml
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/CommitLocalTransactionRequest.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ConnectClientSuccess.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequest.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/AbstractSuccessProxy.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/FrontendType.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/MemberName.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/TransactionIdentifier.java

index c8ab1a3..8783ce6 100644 (file)
             <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>
 
index a1aa399..4951110 100644 (file)
@@ -11,6 +11,7 @@ import akka.actor.ActorRef;
 import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.base.Preconditions;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
@@ -25,6 +26,10 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification
 public final class CommitLocalTransactionRequest
         extends AbstractLocalTransactionRequest<CommitLocalTransactionRequest> {
     private static final long serialVersionUID = 1L;
+
+    @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "This field is not Serializable but this class "
+            + "implements writeReplace to delegate serialization to a Proxy class and thus instances of this class "
+            + "aren't serialized. FindBugs does not recognize this.")
     private final DataTreeModification mod;
     private final boolean coordinated;
 
index 450ef4a..c813605 100644 (file)
@@ -13,6 +13,7 @@ import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.List;
 import java.util.Optional;
 import javax.annotation.Nonnull;
@@ -32,7 +33,12 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 public final class ConnectClientSuccess extends RequestSuccess<ClientIdentifier, ConnectClientSuccess> {
     private static final long serialVersionUID = 1L;
 
+    @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "This field is not Serializable but this class "
+            + "implements writeReplace to delegate serialization to a Proxy class and thus instances of this class "
+            + "aren't serialized. FindBugs does not recognize this.")
     private final List<ActorSelection> alternates;
+
+    @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "See justification above.")
     private final DataTree dataTree;
     private final ActorRef backend;
     private final int maxMessages;
index 416297d..0f01ee5 100644 (file)
@@ -11,6 +11,7 @@ import akka.actor.ActorRef;
 import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.collect.ImmutableList;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.List;
 import java.util.Optional;
 import org.opendaylight.controller.cluster.access.ABIVersion;
@@ -25,6 +26,10 @@ import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier
 @Beta
 public final class ModifyTransactionRequest extends TransactionRequest<ModifyTransactionRequest> {
     private static final long serialVersionUID = 1L;
+
+    @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "This field is not Serializable but this class "
+            + "implements writeReplace to delegate serialization to a Proxy class and thus instances of this class "
+            + "aren't serialized. FindBugs does not recognize this.")
     private final List<TransactionModification> modifications;
     private final PersistenceProtocol protocol;
 
index 4404b01..6a46f23 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.controller.cluster.access.concepts;
 
 import com.google.common.annotations.Beta;
-import java.io.Externalizable;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.concepts.WritableIdentifier;
 
@@ -21,7 +20,7 @@ import org.opendaylight.yangtools.concepts.WritableIdentifier;
  */
 @Beta
 public abstract class AbstractSuccessProxy<T extends WritableIdentifier, C extends RequestSuccess<T, C>>
-        extends AbstractResponseProxy<T, C> implements Externalizable {
+        extends AbstractResponseProxy<T, C> {
     private static final long serialVersionUID = 1L;
 
     protected AbstractSuccessProxy() {
index b58e240..95857e8 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.base.MoreObjects;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.common.base.Verify;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.Externalizable;
@@ -71,6 +72,9 @@ public final class FrontendType implements Comparable<FrontendType>, WritableIde
     private static final Pattern SIMPLE_STRING_PATTERN = Pattern.compile(SIMPLE_STRING_REGEX);
     private static final long serialVersionUID = 1L;
     private final String name;
+
+    @SuppressFBWarnings(value = "VO_VOLATILE_REFERENCE_TO_ARRAY",
+            justification = "The array elements are non-volatile but we don't access them.")
     private volatile byte[] serialized;
 
     private FrontendType(final String name) {
index 55737c4..09e39e8 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.base.MoreObjects;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.common.base.Verify;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.Externalizable;
@@ -63,6 +64,9 @@ public final class MemberName implements Comparable<MemberName>, WritableIdentif
 
     private static final long serialVersionUID = 1L;
     private final String name;
+
+    @SuppressFBWarnings(value = "VO_VOLATILE_REFERENCE_TO_ARRAY",
+            justification = "The array elements are non-volatile but we don't access them.")
     private volatile byte[] serialized;
 
     private MemberName(final String name) {
index 202b5ce..405d1f9 100644 (file)
@@ -63,7 +63,7 @@ public final class TransactionIdentifier implements WritableIdentifier {
     private static final long serialVersionUID = 1L;
     private final LocalHistoryIdentifier historyId;
     private final long transactionId;
-    private transient String shortString;
+    private String shortString;
 
     public TransactionIdentifier(@Nonnull final LocalHistoryIdentifier historyId, final long transactionId) {
         this.historyId = Preconditions.checkNotNull(historyId);

©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.