You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2018/09/10 01:16:07 UTC
[accumulo] 02/02: Upgrade findbugs to spotbugs for 1.9
This is an automated email from the ASF dual-hosted git repository.
ctubbsii pushed a commit to branch 1.9
in repository https://gitbox.apache.org/repos/asf/accumulo.git
commit bc260dcd6cc1c4a2bb1a4b79c0c65d5b4df1eac7
Author: Mike Miller <mm...@apache.org>
AuthorDate: Tue Aug 28 00:01:08 2018 -0400
Upgrade findbugs to spotbugs for 1.9
(Backport of #615 to the 1.9 branch with some updates)
* Upgrade findbugs to spotbugs 3.1.6
* Rename all findbugs to spotbugs (with various capitalizations)
* Remove README.spotbugs/README.findbugs (contains incorrect info and not useful)
---
contrib/README.findbugs | 24 -------------
.../accumulo/core/data/impl/TabletIdImpl.java | 7 ++--
.../impl/SeekableByteArrayInputStream.java | 4 +--
.../main/{findbugs => spotbugs}/exclude-filter.xml | 0
.../accumulo/core/client/rfile/RFileTest.java | 7 ++--
.../examples/simple/client/RandomBatchWriter.java | 4 +--
.../main/{findbugs => spotbugs}/exclude-filter.xml | 0
.../main/{findbugs => spotbugs}/exclude-filter.xml | 0
.../main/{findbugs => spotbugs}/exclude-filter.xml | 0
pom.xml | 42 ++++++++++++++++------
.../main/{findbugs => spotbugs}/exclude-filter.xml | 0
.../main/{findbugs => spotbugs}/exclude-filter.xml | 0
.../main/{findbugs => spotbugs}/exclude-filter.xml | 0
.../main/{findbugs => spotbugs}/exclude-filter.xml | 0
.../main/{findbugs => spotbugs}/exclude-filter.xml | 0
.../main/{findbugs => spotbugs}/exclude-filter.xml | 0
.../main/{findbugs => spotbugs}/exclude-filter.xml | 0
.../org/apache/accumulo/test/InMemoryMapIT.java | 2 +-
.../org/apache/accumulo/test/ShellServerIT.java | 12 +++----
.../main/{findbugs => spotbugs}/exclude-filter.xml | 0
.../main/{findbugs => spotbugs}/exclude-filter.xml | 0
21 files changed, 45 insertions(+), 57 deletions(-)
diff --git a/contrib/README.findbugs b/contrib/README.findbugs
deleted file mode 100644
index 7e70014..0000000
--- a/contrib/README.findbugs
+++ /dev/null
@@ -1,24 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-To generate a Findbugs report, invoke the following Maven command from the root
-of the project:
-
-`mvn clean package site site:stage`
-
-Activating the package lifecycle phase is necessary as recompilation of the
-classes is necessary to get instrumentation from Findbugs. This will ultimately
-generate a local HTML site in `target/staging` which you can point your web
-browser to. Each submodule of the project will contain its own Findbugs report.
diff --git a/core/src/main/java/org/apache/accumulo/core/data/impl/TabletIdImpl.java b/core/src/main/java/org/apache/accumulo/core/data/impl/TabletIdImpl.java
index 81486e0..24fa4b2 100644
--- a/core/src/main/java/org/apache/accumulo/core/data/impl/TabletIdImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/data/impl/TabletIdImpl.java
@@ -33,13 +33,10 @@ public class TabletIdImpl implements TabletId {
new Function<org.apache.accumulo.core.data.KeyExtent,TabletId>() {
@Override
public TabletId apply(org.apache.accumulo.core.data.KeyExtent input) {
- // the following if null check is to appease findbugs... grumble grumble spent a good part of
- // my morning looking into this
+ // Ensure parameter isn't null; see also:
// http://sourceforge.net/p/findbugs/bugs/1139/
// https://code.google.com/p/guava-libraries/issues/detail?id=920
- if (input == null)
- return null;
- return new TabletIdImpl(input);
+ return input == null ? null : new TabletIdImpl(input);
}
};
// @formatter:on
diff --git a/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/SeekableByteArrayInputStream.java b/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/SeekableByteArrayInputStream.java
index 43ca811..e9407e1 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/SeekableByteArrayInputStream.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/SeekableByteArrayInputStream.java
@@ -31,8 +31,8 @@ public class SeekableByteArrayInputStream extends InputStream {
// making this volatile for the following case
// * thread 1 creates and initalizes byte array
// * thread 2 reads from bye array
- // Findbugs complains about this because thread2 may not see any changes to the byte array after
- // thread 1 set the voltile,
+ // spotbugs complains about this because thread2 may not see any changes to the byte array after
+ // thread 1 set the volatile,
// however the expectation is that the byte array is static. In the case of it being static,
// volatile ensures that
// thread 2 sees all of thread 1 changes before setting the volatile.
diff --git a/core/src/main/findbugs/exclude-filter.xml b/core/src/main/spotbugs/exclude-filter.xml
similarity index 100%
rename from core/src/main/findbugs/exclude-filter.xml
rename to core/src/main/spotbugs/exclude-filter.xml
diff --git a/core/src/test/java/org/apache/accumulo/core/client/rfile/RFileTest.java b/core/src/test/java/org/apache/accumulo/core/client/rfile/RFileTest.java
index 33ec8f7..1d9656b 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/rfile/RFileTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/rfile/RFileTest.java
@@ -63,14 +63,11 @@ import com.google.common.collect.ImmutableMap;
public class RFileTest {
- // method created to foil findbugs... it was complaining ret val not used when it did not matter
- private void foo(boolean b) {}
-
private String createTmpTestFile() throws IOException {
File dir = new File(System.getProperty("user.dir") + "/target/rfile-test");
- foo(dir.mkdirs());
+ assertTrue(dir.mkdirs() || dir.isDirectory());
File testFile = File.createTempFile("test", ".rf", dir);
- foo(testFile.delete());
+ assertTrue(testFile.delete() || !testFile.exists());
return testFile.getAbsolutePath();
}
diff --git a/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/RandomBatchWriter.java b/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/RandomBatchWriter.java
index 3ead254..4c5206d 100644
--- a/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/RandomBatchWriter.java
+++ b/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/RandomBatchWriter.java
@@ -128,8 +128,8 @@ public class RandomBatchWriter {
Opts opts = new Opts();
BatchWriterOpts bwOpts = new BatchWriterOpts();
opts.parseArgs(RandomBatchWriter.class.getName(), args, bwOpts);
- if ((opts.max - opts.min) < 1L * opts.num) { // right-side multiplied by 1L to convert to long
- // in a way that doesn't trigger FindBugs
+ // right-side multiplied by 1L to convert to long in a way that doesn't trigger spotbugs
+ if ((opts.max - opts.min) < 1L * opts.num) {
System.err.println(String.format("You must specify a min and a max that"
+ " allow for at least num possible values. For example, you requested"
+ " %d rows, but a min of %d and a max of %d (exclusive), which only"
diff --git a/examples/simple/src/main/findbugs/exclude-filter.xml b/examples/simple/src/main/spotbugs/exclude-filter.xml
similarity index 100%
rename from examples/simple/src/main/findbugs/exclude-filter.xml
rename to examples/simple/src/main/spotbugs/exclude-filter.xml
diff --git a/fate/src/main/findbugs/exclude-filter.xml b/fate/src/main/spotbugs/exclude-filter.xml
similarity index 100%
rename from fate/src/main/findbugs/exclude-filter.xml
rename to fate/src/main/spotbugs/exclude-filter.xml
diff --git a/minicluster/src/main/findbugs/exclude-filter.xml b/minicluster/src/main/spotbugs/exclude-filter.xml
similarity index 100%
rename from minicluster/src/main/findbugs/exclude-filter.xml
rename to minicluster/src/main/spotbugs/exclude-filter.xml
diff --git a/pom.xml b/pom.xml
index a088f85..44d6ada 100644
--- a/pom.xml
+++ b/pom.xml
@@ -125,7 +125,6 @@
<extraReleaseArguments />
<failsafe.excludedGroups />
<failsafe.groups />
- <findbugs.version>3.0.5</findbugs.version>
<!-- surefire/failsafe plugin option -->
<forkCount>1</forkCount>
<hadoop.version>2.6.4</hadoop.version>
@@ -586,9 +585,9 @@
</configuration>
</plugin>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>${findbugs.version}</version>
+ <groupId>com.github.spotbugs</groupId>
+ <artifactId>spotbugs-maven-plugin</artifactId>
+ <version>3.1.6</version>
<configuration>
<xmlOutput>true</xmlOutput>
<effort>Max</effort>
@@ -1053,11 +1052,11 @@
</executions>
</plugin>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
+ <groupId>com.github.spotbugs</groupId>
+ <artifactId>spotbugs-maven-plugin</artifactId>
<executions>
<execution>
- <id>run-findbugs</id>
+ <id>run-spotbugs</id>
<goals>
<goal>check</goal>
</goals>
@@ -1109,6 +1108,27 @@
</build>
<profiles>
<profile>
+ <!-- This profile skips all Quality Assurance checks -->
+ <id>skipQA</id>
+ <properties>
+ <accumulo.skip>true</accumulo.skip>
+ <apilyzer.skip>true</apilyzer.skip>
+ <checkstyle.skip>true</checkstyle.skip>
+ <enforcer.skip>true</enforcer.skip>
+ <formatter.skip>true</formatter.skip>
+ <impsort.skip>true</impsort.skip>
+ <maven.plugin.skip>true</maven.plugin.skip>
+ <mdep.analyze.skip>true</mdep.analyze.skip>
+ <modernizer.skip>true</modernizer.skip>
+ <rat.skip>true</rat.skip>
+ <skipITs>true</skipITs>
+ <skipTests>true</skipTests>
+ <sort.skip>true</sort.skip>
+ <spotbugs.skip>true</spotbugs.skip>
+ <warbucks.skip>true</warbucks.skip>
+ </properties>
+ </profile>
+ <profile>
<id>m2e</id>
<activation>
<property>
@@ -1284,9 +1304,9 @@
<properties>
<!-- some properties to make the release build a bit faster -->
<checkstyle.skip>true</checkstyle.skip>
- <findbugs.skip>true</findbugs.skip>
<skipITs>true</skipITs>
<skipTests>true</skipTests>
+ <spotbugs.skip>true</spotbugs.skip>
</properties>
</profile>
<profile>
@@ -1393,14 +1413,14 @@
</build>
</profile>
<profile>
- <id>add-findbugs-excludes</id>
+ <id>add-spotbugs-excludes</id>
<activation>
<file>
- <exists>src/main/findbugs/exclude-filter.xml</exists>
+ <exists>src/main/spotbugs/exclude-filter.xml</exists>
</file>
</activation>
<properties>
- <findbugs.excludeFilterFile>src/main/findbugs/exclude-filter.xml</findbugs.excludeFilterFile>
+ <spotbugs.excludeFilterFile>src/main/spotbugs/exclude-filter.xml</spotbugs.excludeFilterFile>
</properties>
</profile>
<!-- Active by default, build against Hadoop 2 -->
diff --git a/proxy/src/main/findbugs/exclude-filter.xml b/proxy/src/main/spotbugs/exclude-filter.xml
similarity index 100%
rename from proxy/src/main/findbugs/exclude-filter.xml
rename to proxy/src/main/spotbugs/exclude-filter.xml
diff --git a/server/base/src/main/findbugs/exclude-filter.xml b/server/base/src/main/spotbugs/exclude-filter.xml
similarity index 100%
rename from server/base/src/main/findbugs/exclude-filter.xml
rename to server/base/src/main/spotbugs/exclude-filter.xml
diff --git a/server/gc/src/main/findbugs/exclude-filter.xml b/server/gc/src/main/spotbugs/exclude-filter.xml
similarity index 100%
rename from server/gc/src/main/findbugs/exclude-filter.xml
rename to server/gc/src/main/spotbugs/exclude-filter.xml
diff --git a/server/master/src/main/findbugs/exclude-filter.xml b/server/master/src/main/spotbugs/exclude-filter.xml
similarity index 100%
rename from server/master/src/main/findbugs/exclude-filter.xml
rename to server/master/src/main/spotbugs/exclude-filter.xml
diff --git a/server/tracer/src/main/findbugs/exclude-filter.xml b/server/tracer/src/main/spotbugs/exclude-filter.xml
similarity index 100%
rename from server/tracer/src/main/findbugs/exclude-filter.xml
rename to server/tracer/src/main/spotbugs/exclude-filter.xml
diff --git a/server/tserver/src/main/findbugs/exclude-filter.xml b/server/tserver/src/main/spotbugs/exclude-filter.xml
similarity index 100%
rename from server/tserver/src/main/findbugs/exclude-filter.xml
rename to server/tserver/src/main/spotbugs/exclude-filter.xml
diff --git a/shell/src/main/findbugs/exclude-filter.xml b/shell/src/main/spotbugs/exclude-filter.xml
similarity index 100%
rename from shell/src/main/findbugs/exclude-filter.xml
rename to shell/src/main/spotbugs/exclude-filter.xml
diff --git a/test/src/main/java/org/apache/accumulo/test/InMemoryMapIT.java b/test/src/main/java/org/apache/accumulo/test/InMemoryMapIT.java
index 82b8ae9..37ab78d 100644
--- a/test/src/main/java/org/apache/accumulo/test/InMemoryMapIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/InMemoryMapIT.java
@@ -96,7 +96,7 @@ public class InMemoryMapIT {
fail("Missing the native library from " + nativeMapLocation.getAbsolutePath()
+ "\nYou need to build the libaccumulo binary first. "
+ "\nTry running 'mvn clean verify -Dit.test=InMemoryMapIT -Dtest=foo"
- + " -DfailIfNoTests=false -Dfindbugs.skip -Dcheckstyle.skip'");
+ + " -DfailIfNoTests=false -Dspotbugs.skip -Dcheckstyle.skip'");
}
log.debug("Native map loaded");
diff --git a/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java b/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java
index 22234c8..c6c70f6 100644
--- a/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java
@@ -1773,14 +1773,12 @@ public class ShellServerIT extends SharedMiniClusterBase {
}
@Test
- public void scansWithClassLoaderContext() throws Exception {
+ public void scansWithClassLoaderContext() throws IOException {
try {
Class.forName(VALUE_REVERSING_ITERATOR);
fail("ValueReversingIterator already on the classpath");
- } catch (Exception e) {
- // Do nothing here, This is success. The following line is here
- // so that findbugs doesn't have a stroke.
- assertTrue(true);
+ } catch (ClassNotFoundException e) {
+ // expected; iterator is already on the class path
}
ts.exec("createtable t");
// Assert that the TabletServer does not know anything about our class
@@ -1913,7 +1911,7 @@ public class ShellServerIT extends SharedMiniClusterBase {
private static final String COLUMN_FAMILY_COUNTER_ITERATOR = "org.apache.accumulo.core.iterators"
+ ".ColumnFamilyCounter";
- private void setupRealContextPath() throws Exception {
+ private void setupRealContextPath() throws IOException {
// Copy the test iterators jar to tmp
Path baseDir = new Path(System.getProperty("user.dir"));
Path targetDir = new Path(baseDir, "target");
@@ -1923,7 +1921,7 @@ public class ShellServerIT extends SharedMiniClusterBase {
fs.copyFromLocalFile(jarPath, dstPath);
}
- private void setupFakeContextPath() throws Exception {
+ private void setupFakeContextPath() throws IOException {
// Copy the test iterators jar to tmp
Path baseDir = new Path(System.getProperty("user.dir"));
Path targetDir = new Path(baseDir, "target");
diff --git a/test/src/main/findbugs/exclude-filter.xml b/test/src/main/spotbugs/exclude-filter.xml
similarity index 100%
rename from test/src/main/findbugs/exclude-filter.xml
rename to test/src/main/spotbugs/exclude-filter.xml
diff --git a/trace/src/main/findbugs/exclude-filter.xml b/trace/src/main/spotbugs/exclude-filter.xml
similarity index 100%
rename from trace/src/main/findbugs/exclude-filter.xml
rename to trace/src/main/spotbugs/exclude-filter.xml