Enable findbugs in mockito-configuration 65/76065/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 13 Sep 2018 10:07:13 +0000 (12:07 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 13 Sep 2018 15:10:33 +0000 (17:10 +0200)
This fixes warnings reported and flips the switch.

Change-Id: I4f035e4c3a9c7bc4a764668abb6adb9b8d952c9c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
common/mockito-configuration/pom.xml
common/mockito-configuration/src/main/java/org/mockito/configuration/ArgumentsExtractorVerifier.java
common/mockito-configuration/src/main/java/org/mockito/configuration/ThrowsUnstubbedMethodException.java

index ff7debab94397bc62a32a764b509edf66c94a855..fd6e0c7bb3de4fb0b0d1e504c7b2204e4d8676a4 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>
             <plugin>
                 <groupId>org.jacoco</groupId>
                 <artifactId>jacoco-maven-plugin</artifactId>
index 4112923212e37e748c64d665d2e7ab150fb52be4..ec7fc8e22598e9373bdf664d2c87f5831dd8997e 100644 (file)
@@ -19,7 +19,7 @@ import org.mockito.verification.VerificationMode;
  * Verifier that extracts arguments from actual invocation. Useful when deeper validation of arguments is needed.
  */
 public class ArgumentsExtractorVerifier implements VerificationMode {
-    private Object[] arguments;
+    private Object[] arguments = null;
 
     @Override
     public void verify(final VerificationData data) {
@@ -32,7 +32,6 @@ public class ArgumentsExtractorVerifier implements VerificationMode {
         Invocation invocation = actualInvocations.get(0);
         arguments = invocation.getArguments();
         invocation.markVerified();
-
     }
 
     @Override
@@ -41,6 +40,6 @@ public class ArgumentsExtractorVerifier implements VerificationMode {
     }
 
     public Object[] getArguments() {
-        return arguments;
+        return arguments == null ? null : arguments.clone();
     }
 }
index d03913058841abb88cfd277ba3d7eff78c9edab1..e08b755bb6a53ded43a36ea8a3575723558d65f4 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.mockito.configuration;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.Serializable;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
@@ -14,6 +15,7 @@ import org.mockito.stubbing.Answer;
 /**
  * Answer that throws {@link UnstubbedMethodException}.
  */
+@SuppressFBWarnings("NM_CLASS_NOT_EXCEPTION")
 public class ThrowsUnstubbedMethodException implements Answer<Object>, Serializable {
     private static final long serialVersionUID = 1L;