Skip to content

Commit ed15a22

Browse files
committed
TEZ-4287: Upgrade FindBugs to SpotBugs
1 parent 84b5bd6 commit ed15a22

7 files changed

Lines changed: 64 additions & 103 deletions

File tree

BUILDING.txt

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

99
* JDK 1.8+
1010
* Maven 3.1 or later
11-
* Findbugs 2.0.2 or later (if running findbugs)
1211
* ProtocolBuffer 2.5.0
1312
* Internet connection for first build (to fetch all dependencies)
1413
* Hadoop version should be 2.7.0 or higher.
@@ -36,7 +35,7 @@ Maven build goals:
3635
* Compile : mvn compile
3736
* Run tests : mvn test
3837
* Create JAR : mvn package
39-
* Run findbugs : mvn compile findbugs:findbugs
38+
* Run spotsbugs : mvn compile spotbugs:spotsbugs
4039
* Run checkstyle : mvn compile checkstyle:checkstyle
4140
* Install JAR in M2 cache : mvn install
4241
* Deploy JAR to Maven repo : mvn deploy

build-tools/docker/Dockerfile

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,6 @@ RUN apt-get -q update \
129129
&& rm -rf /var/lib/apt/lists/*
130130
ENV MAVEN_HOME /usr
131131

132-
######
133-
# Install findbugs 3.0.1 (3.0.1 ships with Xenial)
134-
# Ant is needed for findbugs
135-
######
136-
# hadolint ignore=DL3008
137-
RUN apt-get -q update \
138-
&& apt-get -q install -y --no-install-recommends findbugs ant \
139-
&& apt-get clean \
140-
&& rm -rf /var/lib/apt/lists/*
141-
ENV FINDBUGS_HOME /usr
142-
143132
####
144133
# Install shellcheck (0.4.6, the latest as of 2017-09-26)
145134
####

build-tools/test-patch.sh

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

4544
###############################################################################
4645
printUsage() {
@@ -60,7 +59,7 @@ printUsage() {
6059
echo "--grep-cmd=<cmd> The 'grep' command to use (default 'grep')"
6160
echo "--patch-cmd=<cmd> The 'patch' command to use (default 'patch')"
6261
echo "--diff-cmd=<cmd> The 'diff' command to use (default 'diff')"
63-
echo "--findbugs-home=<path> Findbugs home directory (default FINDBUGS_HOME environment variable)"
62+
echo "--spotbugs-home=<path> SpotsBugs home directory (default SPOTBUGS_HOME environment variable)"
6463
echo "--dirty-workspace Allow the local git workspace to have uncommitted changes"
6564
echo "--run-tests Run all tests below the base directory"
6665
echo
@@ -115,8 +114,8 @@ parseArgs() {
115114
--jira-password=*)
116115
JIRA_PASSWD=${i#*=}
117116
;;
118-
--findbugs-home=*)
119-
FINDBUGS_HOME=${i#*=}
117+
--spotbugs-home=*)
118+
SPOTBUGS_HOME=${i#*=}
120119
;;
121120
--dirty-workspace)
122121
DIRTY_WORKSPACE=true
@@ -507,7 +506,7 @@ $JIRA_COMMENT_FOOTER"
507506

508507

509508
###############################################################################
510-
### Install the new jars so tests and findbugs can find all of the updated jars
509+
### Install the new jars so tests and SpotsBugs can find all of the updated jars
511510
buildAndInstall () {
512511
echo ""
513512
echo ""
@@ -525,67 +524,67 @@ buildAndInstall () {
525524

526525

527526
###############################################################################
528-
### Check there are no changes in the number of Findbugs warnings
529-
checkFindbugsWarnings () {
527+
### Check there are no changes in the number of SpotBugs warnings
528+
checkSpotBugsWarnings () {
530529
echo ""
531530
echo ""
532531
echo "======================================================================"
533532
echo "======================================================================"
534-
echo " Determining number of patched Findbugs warnings."
533+
echo " Determining number of patched SpotBugs warnings."
535534
echo "======================================================================"
536535
echo "======================================================================"
537536
echo ""
538537
echo ""
539538

540539
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
540+
echo " Running SpotBugs "
541+
echo "$MVN clean test spotbugs:spotbugs -DskipTests < /dev/null > $PATCH_DIR/patchSpotBugsOutput.txt 2>&1"
542+
$MVN clean test spotbugs:spotbugs -DskipTests < /dev/null > $PATCH_DIR/patchSpotBugsOutput.txt 2>&1
544543
rc=$?
545-
findbugs_version=$(${AWK} 'match($0, /findbugs-maven-plugin:[^:]*:findbugs/) { print substr($0, RSTART + 22, RLENGTH - 31); exit }' "${PATCH_DIR}/patchFindBugsOutput.txt")
544+
spotbugs_version=$(${AWK} 'match($0, /spotbugs-maven-plugin:[^:]*:spotbugs/) { print substr($0, RSTART + 22, RLENGTH - 31); exit }' "${PATCH_DIR}/patchSpotBugsOutput.txt")
546545

547546
if [ $rc != 0 ] ; then
548547
JIRA_COMMENT="$JIRA_COMMENT
549548
550-
{color:red}-1 findbugs{color}. The patch appears to cause Findbugs (version ${findbugs_version}) to fail."
549+
{color:red}-1 spotbugs{color}. The patch appears to cause SpotsBugs (version ${spotbugs_version}) to fail."
551550
return 1
552551
fi
553552

554-
findbugsWarnings=0
555-
for file in $(find $BASEDIR -name findbugsXml.xml)
553+
spotbugsWarnings=0
554+
for file in $(find $BASEDIR -name spotbugsXml.xml)
556555
do
557556
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
557+
if [ ! $relative_file == "target/spotbugsXml.xml" ]; then
558+
module_suffix=${relative_file%/target/spotbugsXml.xml} # strip trailing path
560559
module_suffix=`basename ${module_suffix}`
561560
fi
562561

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
562+
cp $file $PATCH_DIR/patchSpotbugsWarnings${module_suffix}.xml
563+
$SPOTBUGS_HOME/bin/setBugDatabaseInfo -timestamp "01/01/2000" \
564+
$PATCH_DIR/patchSpotbugsWarnings${module_suffix}.xml \
565+
$PATCH_DIR/patchSpotbugsWarnings${module_suffix}.xml
566+
newSpotbugsWarnings=`$SPOTBUGS_HOME/bin/filterBugs -first "01/01/2000" $PATCH_DIR/patchSpotbugsWarnings${module_suffix}.xml \
567+
$PATCH_DIR/newPatchSpotbugsWarnings${module_suffix}.xml | $AWK '{print $1}'`
568+
echo "Found $newSpotbugsWarnings SpotBugs warnings ($file)"
569+
spotbugsWarnings=$((spotbugsWarnings+newSpotbugsWarnings))
570+
$SPOTBUGS_HOME/bin/convertXmlToText -html \
571+
$PATCH_DIR/newPatchSpotbugsWarnings${module_suffix}.xml \
572+
$PATCH_DIR/newPatchSpotbugsWarnings${module_suffix}.html
573+
if [[ $newSpotbugsWarnings > 0 ]] ; then
574+
JIRA_COMMENT_FOOTER="SpotBugs warnings: $BUILD_URL/artifact/patchprocess/newPatchSpotbugsWarnings${module_suffix}.html
576575
$JIRA_COMMENT_FOOTER"
577576
fi
578577
done
579578

580-
if [[ $findbugsWarnings -gt 0 ]] ; then
579+
if [[ $spotbugsWarnings -gt 0 ]] ; then
581580
JIRA_COMMENT="$JIRA_COMMENT
582581
583-
{color:red}-1 findbugs{color}. The patch appears to introduce $findbugsWarnings new Findbugs (version ${findbugs_version}) warnings."
582+
{color:red}-1 spotbugs{color}. The patch appears to introduce $spotbugsWarnings new SpotBugs (version ${spotbugs_version}) warnings."
584583
return 1
585584
fi
586585
JIRA_COMMENT="$JIRA_COMMENT
587586
588-
{color:green}+1 findbugs{color}. The patch does not introduce any new Findbugs (version ${findbugs_version}) warnings."
587+
{color:green}+1 spotbugs{color}. The patch does not introduce any new SpotBugs (version ${spotbugs_version}) warnings."
589588
return 0
590589
}
591590

@@ -805,7 +804,7 @@ fi
805804
checkJavadocWarnings
806805
(( RESULT = RESULT + $? ))
807806
buildAndInstall
808-
checkFindbugsWarnings
807+
checkSpotBugsWarnings
809808
(( RESULT = RESULT + $? ))
810809
checkReleaseAuditWarnings
811810
(( RESULT = RESULT + $? ))

pom.xml

Lines changed: 30 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
<protoc.path>${env.PROTOC_PATH}</protoc.path>
6868
<scm.url>scm:git:https://gitbox.apache.org/repos/asf/tez.git</scm.url>
6969
<frontend-maven-plugin.version>1.4</frontend-maven-plugin.version>
70-
<findbugs-maven-plugin.version>3.0.5</findbugs-maven-plugin.version>
71-
<maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version>
70+
<spotbugs.version>4.1.4</spotbugs.version>
71+
<maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version>
7272
<checkstyle.version>8.35</checkstyle.version>
7373
<dependency-check-maven.version>1.3.6</dependency-check-maven.version>
7474
<test.build.data>${project.build.directory}/tmp</test.build.data>
@@ -700,9 +700,17 @@
700700
<version>1.3.4</version>
701701
</dependency>
702702
<dependency>
703-
<groupId>com.google.code.findbugs</groupId>
704-
<artifactId>jsr305</artifactId>
705-
<version>3.0.0</version>
703+
<groupId>com.github.spotbugs</groupId>
704+
<artifactId>spotbugs-annotations</artifactId>
705+
<version>${spotbugs.version}</version>
706+
<optional>true</optional>
707+
</dependency>
708+
<!-- Dependency for SpotBugs -->
709+
<dependency>
710+
<groupId>net.jcip</groupId>
711+
<artifactId>jcip-annotations</artifactId>
712+
<version>1.0</version>
713+
<optional>true</optional>
706714
</dependency>
707715
<dependency>
708716
<groupId>com.sun.jersey</groupId>
@@ -883,9 +891,13 @@
883891
<version>${dependency-check-maven.version}</version>
884892
</plugin>
885893
<plugin>
886-
<groupId>org.codehaus.mojo</groupId>
887-
<artifactId>findbugs-maven-plugin</artifactId>
888-
<version>${findbugs-maven-plugin.version}</version>
894+
<groupId>com.github.spotbugs</groupId>
895+
<artifactId>spotbugs-maven-plugin</artifactId>
896+
<version>${spotbugs.version}</version>
897+
<configuration>
898+
<excludeFilterFile>${project.basedir}/findbugs-exclude.xml</excludeFilterFile>
899+
<failOnError>false</failOnError>
900+
</configuration>
889901
</plugin>
890902
<plugin>
891903
<groupId>org.codehaus.mojo</groupId>
@@ -1007,11 +1019,8 @@
10071019
<artifactId>build-helper-maven-plugin</artifactId>
10081020
</plugin>
10091021
<plugin>
1010-
<groupId>org.codehaus.mojo</groupId>
1011-
<artifactId>findbugs-maven-plugin</artifactId>
1012-
<configuration>
1013-
<excludeFilterFile>${basedir}/findbugs-exclude.xml</excludeFilterFile>
1014-
</configuration>
1022+
<groupId>com.github.spotbugs</groupId>
1023+
<artifactId>spotbugs-maven-plugin</artifactId>
10151024
</plugin>
10161025
<plugin>
10171026
<!-- OWASP's dependency-check plugin will scan the third party
@@ -1103,45 +1112,23 @@
11031112
</build>
11041113
</profile>
11051114
<profile>
1106-
<id>findbugs</id>
1115+
<id>spotbugs</id>
11071116
<activation>
11081117
<activeByDefault>false</activeByDefault>
11091118
<property>
1110-
<name>findbugs</name>
1119+
<name>spotbugs</name>
11111120
</property>
11121121
</activation>
1113-
<build>
1114-
<plugins>
1115-
<plugin>
1116-
<groupId>org.codehaus.mojo</groupId>
1117-
<artifactId>findbugs-maven-plugin</artifactId>
1118-
<executions>
1119-
<execution>
1120-
<id>site</id>
1121-
<phase>pre-site</phase>
1122-
<goals>
1123-
<goal>findbugs</goal>
1124-
</goals>
1125-
</execution>
1126-
</executions>
1127-
<configuration>
1128-
<excludeFilterFile>${basedir}/findbugs-exclude.xml</excludeFilterFile>
1129-
</configuration>
1130-
</plugin>
1131-
</plugins>
1132-
</build>
11331122
<reporting>
11341123
<plugins>
11351124
<plugin>
1136-
<groupId>org.codehaus.mojo</groupId>
1137-
<artifactId>findbugs-maven-plugin</artifactId>
1125+
<groupId>com.github.spotbugs</groupId>
1126+
<artifactId>spotbugs-maven-plugin</artifactId>
11381127
<configuration>
1139-
<formats>
1140-
<format>xml</format>
1141-
<format>html</format>
1142-
</formats>
1143-
<canGenerate>true</canGenerate>
1144-
<excludeFilterFile>${basedir}/findbugs-exclude.xml</excludeFilterFile>
1128+
<xmlOutput>true</xmlOutput>
1129+
<!-- Optional directory to put spotbugs xdoc xml report -->
1130+
<xmlOutputDirectory>target/site</xmlOutputDirectory>
1131+
<excludeFilterFile>${project.basedir}/findbugs-exclude.xml</excludeFilterFile>
11451132
</configuration>
11461133
</plugin>
11471134
</plugins>

tez-api/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@
8181
<groupId>junit</groupId>
8282
<artifactId>junit</artifactId>
8383
</dependency>
84-
<dependency>
85-
<groupId>com.google.code.findbugs</groupId>
86-
<artifactId>jsr305</artifactId>
87-
</dependency>
8884
<dependency>
8985
<groupId>com.sun.jersey</groupId>
9086
<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
@@ -65,10 +65,6 @@
6565
<groupId>junit</groupId>
6666
<artifactId>junit</artifactId>
6767
</dependency>
68-
<dependency>
69-
<groupId>com.google.code.findbugs</groupId>
70-
<artifactId>jsr305</artifactId>
71-
</dependency>
7268
<dependency>
7369
<groupId>org.mockito</groupId>
7470
<artifactId>mockito-all</artifactId>

0 commit comments

Comments
 (0)