Enable spotbugs in entity-ownership-service 02/76902/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 11 Oct 2018 18:08:51 +0000 (20:08 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 11 Oct 2018 18:08:51 +0000 (20:08 +0200)
This fixes up the issues reported and flips enforcement to on.

Change-Id: Ifd8201eb6ad60c133559bc29b40fda487f4d2c5e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
entityownership/mdsal-eos-binding-adapter/pom.xml
entityownership/mdsal-eos-binding-adapter/src/main/java/org/opendaylight/mdsal/eos/binding/dom/adapter/BindingDOMEntityOwnershipServiceAdapter.java
entityownership/mdsal-eos-binding-adapter/src/main/java/org/opendaylight/mdsal/eos/binding/dom/adapter/DOMEntityOwnershipListenerAdapter.java
entityownership/mdsal-eos-binding-api/pom.xml
entityownership/mdsal-eos-common-api/pom.xml
entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/EntityOwnershipChangeState.java
entityownership/mdsal-eos-common-spi/pom.xml
entityownership/mdsal-eos-dom-api/pom.xml
entityownership/mdsal-eos-dom-simple/pom.xml

index ba32c533c08afb985c36f0b129794f0fed7b0af2..4f062df97b05ba0444b60cb348e22d30f4fb60f1 100644 (file)
                     <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>com.github.spotbugs</groupId>
+                <artifactId>spotbugs-maven-plugin</artifactId>
+                <configuration>
+                    <failOnError>true</failOnError>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
     <scm>
index 97cdb69718e8690624454d26a90d1f2e745f1ba3..b2c80284261bc30769438b58ff8bff3b99dda813 100644 (file)
@@ -21,8 +21,6 @@ import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException
 import org.opendaylight.mdsal.eos.common.api.EntityOwnershipState;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Adapter that bridges between the binding and DOM EntityOwnershipService interfaces.
@@ -30,8 +28,6 @@ import org.slf4j.LoggerFactory;
  * @author Thomas Pantelis
  */
 public class BindingDOMEntityOwnershipServiceAdapter implements EntityOwnershipService, AutoCloseable {
-    static final Logger LOG = LoggerFactory.getLogger(BindingDOMEntityOwnershipServiceAdapter.class);
-
     private final @NonNull DOMEntityOwnershipService domService;
     private final @NonNull BindingNormalizedNodeSerializer conversionCodec;
 
index d8a681532202b788cb694fb627026749b3322963..03cf420b6edc5e83f04c7e8b23111019cf441031 100644 (file)
@@ -8,12 +8,15 @@
 package org.opendaylight.mdsal.eos.binding.dom.adapter;
 
 import com.google.common.base.Preconditions;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
 import org.opendaylight.mdsal.eos.binding.api.Entity;
 import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipChange;
 import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListener;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipChange;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Adapter that bridges between the binding and DOM EntityOwnershipListener interfaces.
@@ -21,6 +24,8 @@ import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
  * @author Thomas Pantelis
  */
 class DOMEntityOwnershipListenerAdapter implements DOMEntityOwnershipListener {
+    private static final Logger LOG = LoggerFactory.getLogger(DOMEntityOwnershipListenerAdapter.class);
+
     private final BindingNormalizedNodeSerializer conversionCodec;
     private final EntityOwnershipListener bindingListener;
 
@@ -30,8 +35,9 @@ class DOMEntityOwnershipListenerAdapter implements DOMEntityOwnershipListener {
         this.conversionCodec = Preconditions.checkNotNull(conversionCodec);
     }
 
-    @SuppressWarnings("checkstyle:IllegalCatch")
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
     public void ownershipChanged(final DOMEntityOwnershipChange ownershipChange) {
         try {
             final Entity entity = new Entity(ownershipChange.getEntity().getType(),
@@ -39,8 +45,7 @@ class DOMEntityOwnershipListenerAdapter implements DOMEntityOwnershipListener {
             bindingListener.ownershipChanged(new EntityOwnershipChange(entity, ownershipChange.getState(),
                     ownershipChange.inJeopardy()));
         } catch (final Exception e) {
-            BindingDOMEntityOwnershipServiceAdapter.LOG.error(
-                    "Error converting DOM entity ID {} to binding InstanceIdentifier",
+            LOG.error("Error converting DOM entity ID {} to binding InstanceIdentifier",
                         ownershipChange.getEntity().getIdentifier(), e);
         }
     }
index 04fbb1c2a19191e0d12eed19801bc9863825c4ef..d759c8cf88769e52f3d7ce661645f0ad1682bc10 100644 (file)
                     <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>com.github.spotbugs</groupId>
+                <artifactId>spotbugs-maven-plugin</artifactId>
+                <configuration>
+                    <failOnError>true</failOnError>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
     <scm>
index a0f4f97d48c5fdf1ceb3997a34dff468508fcb6a..ed6fef34cf5b672ae69aa9b8e0c163530af7fd87 100644 (file)
                     <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>com.github.spotbugs</groupId>
+                <artifactId>spotbugs-maven-plugin</artifactId>
+                <configuration>
+                    <failOnError>true</failOnError>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
     <scm>
index b461ef44a737acba9dc556f8fc1644fecaa235dc..16237900879ac7eb794821efbcde15422b79db13 100644 (file)
@@ -132,6 +132,12 @@ public enum EntityOwnershipChangeState {
 
         @Override
         public boolean equals(final Object obj) {
+            if (obj == this) {
+                return true;
+            }
+            if (!(obj instanceof Key)) {
+                return false;
+            }
             final Key other = (Key) obj;
             return hasOwner == other.hasOwner && isOwner == other.isOwner && wasOwner == other.wasOwner;
         }
index 9ca41c58bc78c42fbee2762cdbd9959c4cc4b7f8..f359ec598252b72f2ee0041399b18a9a902b7d3a 100644 (file)
                     <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>com.github.spotbugs</groupId>
+                <artifactId>spotbugs-maven-plugin</artifactId>
+                <configuration>
+                    <failOnError>true</failOnError>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
     <scm>
index 0d60abcb6a68609dacffbfa2ac972ca23bcdd08a..b0413178ce173b53b133f52c8f4f0ccedda5cb3b 100644 (file)
                     <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>com.github.spotbugs</groupId>
+                <artifactId>spotbugs-maven-plugin</artifactId>
+                <configuration>
+                    <failOnError>true</failOnError>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
     <scm>
index 79d8a1f68c11720502bb814dd90efd4fcc2799f2..aaeb51e01c5284e6cae17ee3ae1dfc768aa93cff 100644 (file)
             <artifactId>metainf-services</artifactId>
             <optional>true</optional>
         </dependency>
-
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-        </dependency>
     </dependencies>
 
     <build>
                     <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>com.github.spotbugs</groupId>
+                <artifactId>spotbugs-maven-plugin</artifactId>
+                <configuration>
+                    <failOnError>true</failOnError>
+                </configuration>
+            </plugin>
         </plugins>
     </build>