Skip to content

Commit a9beee6

Browse files
committed
TEZ-4624: Replace findbugs plugin with spotbugs
1 parent 6d25c3c commit a9beee6

File tree

8 files changed

+87
-118
lines changed

8 files changed

+87
-118
lines changed

BUILDING.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Requirements:
88

99
* JDK 1.8+
1010
* Maven 3.6.3 or later
11-
* Findbugs 2.0.2 or later (if running findbugs)
11+
* spotbugs 4.9.3 or later (if running spotbugs)
1212
* ProtocolBuffer 3.21.1
1313
* Internet connection for first build (to fetch all dependencies)
1414
* Hadoop version should be 2.7.0 or higher.
@@ -36,7 +36,7 @@ Maven build goals:
3636
* Compile : mvn compile
3737
* Run tests : mvn test
3838
* Create JAR : mvn package
39-
* Run findbugs : mvn compile findbugs:findbugs
39+
* Run spotbugs : mvn compile spotbugs:spotbugs
4040
* Run checkstyle : mvn compile checkstyle:checkstyle
4141
* Install JAR in M2 cache : mvn install
4242
* Deploy JAR to Maven repo : mvn deploy

Jenkinsfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,10 @@ pipeline {
117117
YETUS_ARGS+=("--proclimit=5500")
118118
YETUS_ARGS+=("--dockermemlimit=20g")
119119
120-
# -1 findbugs issues that show up prior to the patch being applied
121-
# YETUS_ARGS+=("--findbugs-strict-precheck")
122-
120+
# -1 spotbugs issues that show up prior to the patch being applied
121+
# YETUS_ARGS+=("--spotbugs-strict-precheck")
123122
# rsync these files back into the archive dir
124-
YETUS_ARGS+=("--archive-list=checkstyle-errors.xml,findbugsXml.xml")
123+
YETUS_ARGS+=("--archive-list=checkstyle-errors.xml,spotbugsXml.xml")
125124
126125
# URL for user-side presentation in reports and such to our artifacts
127126
# (needs to match the archive bits below)

build-tools/docker/Dockerfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,14 @@ RUN java -version 2>&1 | grep "1.8.0" && rm -f /usr/lib/jvm/default-java \
190190
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
191191

192192
######
193-
# Install findbugs
193+
# Install SpotBugs 4.2.2
194194
######
195-
# hadolint ignore=DL3008
196-
RUN apt-get -q update && apt-get -q install --no-install-recommends -y findbugs \
197-
&& apt-get clean \
198-
&& rm -rf /var/lib/apt/lists/*
199-
ENV FINDBUGS_HOME /usr
195+
RUN mkdir -p /opt/spotbugs \
196+
&& curl -L -s -S https://github.com/spotbugs/spotbugs/releases/download/4.2.2/spotbugs-4.2.2.tgz \
197+
-o /opt/spotbugs.tgz \
198+
&& tar xzf /opt/spotbugs.tgz --strip-components 1 -C /opt/spotbugs \
199+
&& chmod +x /opt/spotbugs/bin/*
200+
ENV SPOTBUGS_HOME /opt/spotbugs
200201

201202
######
202203
# Install maven

build-tools/test-patch.sh

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ DIFF=${DIFF:-diff}
4040
JIRACLI=${JIRA:-jira}
4141
SED=${SED:-sed}
4242
CURL=${CURL:-curl}
43-
FINDBUGS_HOME=${FINDBUGS_HOME}
43+
SPOTBUGS_HOME=${SPOTBUGS_HOME}
4444

4545
###############################################################################
4646
printUsage() {
@@ -60,7 +60,7 @@ printUsage() {
6060
echo "--grep-cmd=<cmd> The 'grep' command to use (default 'grep')"
6161
echo "--patch-cmd=<cmd> The 'patch' command to use (default 'patch')"
6262
echo "--diff-cmd=<cmd> The 'diff' command to use (default 'diff')"
63-
echo "--findbugs-home=<path> Findbugs home directory (default FINDBUGS_HOME environment variable)"
63+
echo "--spotbugs-home=<path> Spotbugs home directory (default SPOTBUGS_HOME environment variable)"
6464
echo "--dirty-workspace Allow the local git workspace to have uncommitted changes"
6565
echo "--run-tests Run all tests below the base directory"
6666
echo
@@ -115,8 +115,8 @@ parseArgs() {
115115
--jira-password=*)
116116
JIRA_PASSWD=${i#*=}
117117
;;
118-
--findbugs-home=*)
119-
FINDBUGS_HOME=${i#*=}
118+
--spotbugs-home=*)
119+
SPOTBUGS_HOME=${i#*=}
120120
;;
121121
--dirty-workspace)
122122
DIRTY_WORKSPACE=true
@@ -507,7 +507,7 @@ $JIRA_COMMENT_FOOTER"
507507

508508

509509
###############################################################################
510-
### Install the new jars so tests and findbugs can find all of the updated jars
510+
### Install the new jars so tests and spotbugs can find all of the updated jars
511511
buildAndInstall () {
512512
echo ""
513513
echo ""
@@ -525,67 +525,67 @@ buildAndInstall () {
525525

526526

527527
###############################################################################
528-
### Check there are no changes in the number of Findbugs warnings
529-
checkFindbugsWarnings () {
528+
### Check there are no changes in the number of Spotbugs warnings
529+
checkSpotbugsWarnings () {
530530
echo ""
531531
echo ""
532532
echo "======================================================================"
533533
echo "======================================================================"
534-
echo " Determining number of patched Findbugs warnings."
534+
echo " Determining number of patched Spotbugs warnings."
535535
echo "======================================================================"
536536
echo "======================================================================"
537537
echo ""
538538
echo ""
539539

540540
rc=0
541-
echo " Running findbugs "
542-
echo "$MVN clean test findbugs:findbugs -DskipTests < /dev/null > $PATCH_DIR/patchFindBugsOutput.txt 2>&1"
543-
$MVN clean test findbugs:findbugs -DskipTests < /dev/null > $PATCH_DIR/patchFindBugsOutput.txt 2>&1
541+
echo " Running spotbugs "
542+
echo "$MVN clean test spotbugs:spotbugs -DskipTests < /dev/null > $PATCH_DIR/patchSpotBugsOutput.txt 2>&1"
543+
$MVN clean test spotbugs:spotbugs -DskipTests < /dev/null > $PATCH_DIR/patchSpotBugsOutput.txt 2>&1
544544
rc=$?
545-
findbugs_version=$(${AWK} 'match($0, /findbugs-maven-plugin:[^:]*:findbugs/) { print substr($0, RSTART + 22, RLENGTH - 31); exit }' "${PATCH_DIR}/patchFindBugsOutput.txt")
545+
spotbugs_version=$(${AWK} 'match($0, /spotbugs-maven-plugin:[^:]*:spotbugs/) { print substr($0, RSTART + 22, RLENGTH - 31); exit }' "${PATCH_DIR}/patchSpotBugsOutput.txt")
546546

547547
if [ $rc != 0 ] ; then
548548
JIRA_COMMENT="$JIRA_COMMENT
549549
550-
{color:red}-1 findbugs{color}. The patch appears to cause Findbugs (version ${findbugs_version}) to fail."
550+
{color:red}-1 spotbugs{color}. The patch appears to cause Spotbugs (version ${spotbugs_version}) to fail."
551551
return 1
552552
fi
553553

554-
findbugsWarnings=0
555-
for file in $(find $BASEDIR -name findbugsXml.xml)
554+
spotbugsWarnings=0
555+
for file in $(find $BASEDIR -name spotbugsXml.xml)
556556
do
557557
relative_file=${file#$BASEDIR/} # strip leading $BASEDIR prefix
558-
if [ ! $relative_file == "target/findbugsXml.xml" ]; then
559-
module_suffix=${relative_file%/target/findbugsXml.xml} # strip trailing path
558+
if [ ! $relative_file == "target/spotbugsXml.xml" ]; then
559+
module_suffix=${relative_file%/target/spotbugsXml.xml} # strip trailing path
560560
module_suffix=`basename ${module_suffix}`
561561
fi
562562

563-
cp $file $PATCH_DIR/patchFindbugsWarnings${module_suffix}.xml
564-
$FINDBUGS_HOME/bin/setBugDatabaseInfo -timestamp "01/01/2000" \
565-
$PATCH_DIR/patchFindbugsWarnings${module_suffix}.xml \
566-
$PATCH_DIR/patchFindbugsWarnings${module_suffix}.xml
567-
newFindbugsWarnings=`$FINDBUGS_HOME/bin/filterBugs -first "01/01/2000" $PATCH_DIR/patchFindbugsWarnings${module_suffix}.xml \
568-
$PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.xml | $AWK '{print $1}'`
569-
echo "Found $newFindbugsWarnings Findbugs warnings ($file)"
570-
findbugsWarnings=$((findbugsWarnings+newFindbugsWarnings))
571-
$FINDBUGS_HOME/bin/convertXmlToText -html \
572-
$PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.xml \
573-
$PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.html
574-
if [[ $newFindbugsWarnings > 0 ]] ; then
575-
JIRA_COMMENT_FOOTER="Findbugs warnings: $BUILD_URL/artifact/patchprocess/newPatchFindbugsWarnings${module_suffix}.html
563+
cp $file $PATCH_DIR/patchSpotbugsWarnings${module_suffix}.xml
564+
$SPOTBUGS_HOME/bin/setBugDatabaseInfo -timestamp "01/01/2000" \
565+
$PATCH_DIR/patchSpotbugsWarnings${module_suffix}.xml \
566+
$PATCH_DIR/patchSpotbugsWarnings${module_suffix}.xml
567+
newSpotbugsWarnings=`$SPOTBUGS_HOME/bin/filterBugs -first "01/01/2000" $PATCH_DIR/patchSpotbugsWarnings${module_suffix}.xml \
568+
$PATCH_DIR/newPatchSpotbugsWarnings${module_suffix}.xml | $AWK '{print $1}'`
569+
echo "Found $newSpotbugsWarnings Spotbugs warnings ($file)"
570+
spotbugsWarnings=$((spotbugsWarnings+newSpotbugsWarnings))
571+
$SPOTBUGS_HOME/bin/convertXmlToText -html \
572+
$PATCH_DIR/newPatchSpotbugsWarnings${module_suffix}.xml \
573+
$PATCH_DIR/newPatchSpotbugsWarnings${module_suffix}.html
574+
if [[ $newSpotbugsWarnings > 0 ]] ; then
575+
JIRA_COMMENT_FOOTER="Spotbugs warnings: $BUILD_URL/artifact/patchprocess/newPatchSpotbugsWarnings${module_suffix}.html
576576
$JIRA_COMMENT_FOOTER"
577577
fi
578578
done
579579

580-
if [[ $findbugsWarnings -gt 0 ]] ; then
580+
if [[ $spotbugsWarnings -gt 0 ]] ; then
581581
JIRA_COMMENT="$JIRA_COMMENT
582582
583-
{color:red}-1 findbugs{color}. The patch appears to introduce $findbugsWarnings new Findbugs (version ${findbugs_version}) warnings."
583+
{color:red}-1 spotbugs{color}. The patch appears to introduce $spotbugsWarnings new Spotbugs (version ${spotbugs_version}) warnings."
584584
return 1
585585
fi
586586
JIRA_COMMENT="$JIRA_COMMENT
587587
588-
{color:green}+1 findbugs{color}. The patch does not introduce any new Findbugs (version ${findbugs_version}) warnings."
588+
{color:green}+1 spotbugs{color}. The patch does not introduce any new Spotbugs (version ${spotbugs_version}) warnings."
589589
return 0
590590
}
591591

@@ -805,7 +805,7 @@ fi
805805
checkJavadocWarnings
806806
(( RESULT = RESULT + $? ))
807807
buildAndInstall
808-
checkFindbugsWarnings
808+
checkSpotbugsWarnings
809809
(( RESULT = RESULT + $? ))
810810
checkReleaseAuditWarnings
811811
(( RESULT = RESULT + $? ))

pom.xml

Lines changed: 41 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070
<commons-lang.version>2.6</commons-lang.version>
7171
<clover.license>${user.home}/clover.license</clover.license>
7272
<dependency-check-maven.version>3.2.0</dependency-check-maven.version>
73-
<findbugs-maven-plugin.version>3.0.5</findbugs-maven-plugin.version>
73+
<spotbugs.version>4.9.3</spotbugs.version>
74+
<spotbugs-maven-plugin.version>4.9.3.0</spotbugs-maven-plugin.version>
7475
<frontend-maven-plugin.version>1.8.0</frontend-maven-plugin.version>
7576
<guava.version>32.0.1-jre</guava.version>
7677
<hadoop.version>3.4.1</hadoop.version>
@@ -770,11 +771,6 @@
770771
<artifactId>jettison</artifactId>
771772
<version>${jettison.version}</version>
772773
</dependency>
773-
<dependency>
774-
<groupId>com.google.code.findbugs</groupId>
775-
<artifactId>jsr305</artifactId>
776-
<version>${jsr305.version}</version>
777-
</dependency>
778774
<dependency>
779775
<groupId>com.sun.jersey</groupId>
780776
<artifactId>jersey-client</artifactId>
@@ -970,9 +966,20 @@
970966
<version>${dependency-check-maven.version}</version>
971967
</plugin>
972968
<plugin>
973-
<groupId>org.codehaus.mojo</groupId>
974-
<artifactId>findbugs-maven-plugin</artifactId>
975-
<version>${findbugs-maven-plugin.version}</version>
969+
<groupId>com.github.spotbugs</groupId>
970+
<artifactId>spotbugs-maven-plugin</artifactId>
971+
<version>${spotbugs-maven-plugin.version}</version>
972+
<dependencies>
973+
<dependency>
974+
<groupId>com.github.spotbugs</groupId>
975+
<artifactId>spotbugs</artifactId>
976+
<version>${spotbugs.version}</version>
977+
</dependency>
978+
</dependencies>
979+
<configuration>
980+
<excludeFilterFile>${basedir}/findbugs-exclude.xml</excludeFilterFile>
981+
<failOnError>false</failOnError>
982+
</configuration>
976983
</plugin>
977984
<plugin>
978985
<groupId>org.codehaus.mojo</groupId>
@@ -1119,11 +1126,8 @@
11191126
<artifactId>build-helper-maven-plugin</artifactId>
11201127
</plugin>
11211128
<plugin>
1122-
<groupId>org.codehaus.mojo</groupId>
1123-
<artifactId>findbugs-maven-plugin</artifactId>
1124-
<configuration>
1125-
<excludeFilterFile>${basedir}/findbugs-exclude.xml</excludeFilterFile>
1126-
</configuration>
1129+
<groupId>com.github.spotbugs</groupId>
1130+
<artifactId>spotbugs-maven-plugin</artifactId>
11271131
</plugin>
11281132
<plugin>
11291133
<!-- OWASP's dependency-check plugin will scan the third party
@@ -1214,51 +1218,6 @@
12141218
</plugins>
12151219
</build>
12161220
</profile>
1217-
<profile>
1218-
<id>findbugs</id>
1219-
<activation>
1220-
<activeByDefault>false</activeByDefault>
1221-
<property>
1222-
<name>findbugs</name>
1223-
</property>
1224-
</activation>
1225-
<build>
1226-
<plugins>
1227-
<plugin>
1228-
<groupId>org.codehaus.mojo</groupId>
1229-
<artifactId>findbugs-maven-plugin</artifactId>
1230-
<executions>
1231-
<execution>
1232-
<id>site</id>
1233-
<phase>pre-site</phase>
1234-
<goals>
1235-
<goal>findbugs</goal>
1236-
</goals>
1237-
</execution>
1238-
</executions>
1239-
<configuration>
1240-
<excludeFilterFile>${basedir}/findbugs-exclude.xml</excludeFilterFile>
1241-
</configuration>
1242-
</plugin>
1243-
</plugins>
1244-
</build>
1245-
<reporting>
1246-
<plugins>
1247-
<plugin>
1248-
<groupId>org.codehaus.mojo</groupId>
1249-
<artifactId>findbugs-maven-plugin</artifactId>
1250-
<configuration>
1251-
<formats>
1252-
<format>xml</format>
1253-
<format>html</format>
1254-
</formats>
1255-
<canGenerate>true</canGenerate>
1256-
<excludeFilterFile>${basedir}/findbugs-exclude.xml</excludeFilterFile>
1257-
</configuration>
1258-
</plugin>
1259-
</plugins>
1260-
</reporting>
1261-
</profile>
12621221
<profile>
12631222
<id>sources</id>
12641223
<build>
@@ -1383,6 +1342,29 @@
13831342
</dependency>
13841343
</dependencies>
13851344
</profile>
1345+
<profile>
1346+
<id>spotbugs</id>
1347+
<activation>
1348+
<activeByDefault>false</activeByDefault>
1349+
<property>
1350+
<name>spotbugs</name>
1351+
</property>
1352+
</activation>
1353+
<reporting>
1354+
<plugins>
1355+
<plugin>
1356+
<groupId>com.github.spotbugs</groupId>
1357+
<artifactId>spotbugs-maven-plugin</artifactId>
1358+
<configuration>
1359+
<xmlOutput>true</xmlOutput>
1360+
<!-- Optional directory to put spotbugs xdoc xml report -->
1361+
<xmlOutputDirectory>target/site</xmlOutputDirectory>
1362+
<excludeFilterFile>${basedir}/findbugs-exclude.xml</excludeFilterFile>
1363+
</configuration>
1364+
</plugin>
1365+
</plugins>
1366+
</reporting>
1367+
</profile>
13861368
</profiles>
13871369

13881370
<!-- TODO: TEZ-4597: IncludePublicAnnotationsStandardDoclet is not JDK9+ compatible -->

tez-api/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,6 @@
8585
<groupId>junit</groupId>
8686
<artifactId>junit</artifactId>
8787
</dependency>
88-
<dependency>
89-
<groupId>com.google.code.findbugs</groupId>
90-
<artifactId>jsr305</artifactId>
91-
</dependency>
9288
<dependency>
9389
<groupId>com.sun.jersey</groupId>
9490
<artifactId>jersey-client</artifactId>

tez-dag/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,6 @@
111111
<groupId>commons-cli</groupId>
112112
<artifactId>commons-cli</artifactId>
113113
</dependency>
114-
<dependency>
115-
<groupId>com.google.code.findbugs</groupId>
116-
<artifactId>jsr305</artifactId>
117-
<scope>compile</scope>
118-
</dependency>
119114
<dependency>
120115
<groupId>org.apache.commons</groupId>
121116
<artifactId>commons-collections4</artifactId>

tez-runtime-internals/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@
8686
<groupId>junit</groupId>
8787
<artifactId>junit</artifactId>
8888
</dependency>
89-
<dependency>
90-
<groupId>com.google.code.findbugs</groupId>
91-
<artifactId>jsr305</artifactId>
92-
</dependency>
9389
<dependency>
9490
<groupId>org.mockito</groupId>
9591
<artifactId>mockito-core</artifactId>

0 commit comments

Comments
 (0)