You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2022/01/01 21:04:26 UTC

[tomcat] branch main updated (2e0f278 -> 9c377b6)

This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git.


    from 2e0f278  Improve escaping for code in call method
     new be99e04  FindBugs -> SpotBugs (rename)
     new b15e531  Exclude the SpotBug ranks we (currently) aren't looking at
     new 29a6511  Update SpotBugs to 4.5.2
     new 9c377b6  Fix a number of SpotBugs false positives.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 BUILDING.txt                                       | 16 ++--
 build.properties.default                           | 18 ++---
 build.xml                                          | 50 ++++++------
 .../filter-false-positives.xml                     | 90 +++++++++++++++++++++-
 webapps/docs/changelog.xml                         |  3 +
 5 files changed, 132 insertions(+), 45 deletions(-)
 rename res/{findbugs => spotbugs}/filter-false-positives.xml (96%)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 04/04: Fix a number of SpotBugs false positives.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 9c377b604f5396d9dede252a27eb76e43c750898
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Sat Jan 1 21:04:05 2022 +0000

    Fix a number of SpotBugs false positives.
---
 res/spotbugs/filter-false-positives.xml | 77 ++++++++++++++++++++++++++++++++-
 1 file changed, 76 insertions(+), 1 deletion(-)

diff --git a/res/spotbugs/filter-false-positives.xml b/res/spotbugs/filter-false-positives.xml
index e29e513..b32add4 100644
--- a/res/spotbugs/filter-false-positives.xml
+++ b/res/spotbugs/filter-false-positives.xml
@@ -371,6 +371,14 @@
     <Bug pattern="VO_VOLATILE_REFERENCE_TO_ARRAY" />
   </Match>
   <Match>
+    <!-- Not catching NPE would require generating an NPE and then wrapping
+         it because there is no MBeanException(String) constructor. It is
+         cleaner to catch the NPE. -->
+    <Class name="org.apache.catalina.mbeans.ContainerMBean" />
+    <Method name="removeValve" />
+    <Bug pattern="DCN_NULLPOINTER_EXCEPTION" />
+  </Match>
+  <Match>
     <!-- SQL construction is safe since it is from trusted config -->
     <Class name="org.apache.catalina.realm.DataSourceRealm" />
     <Or>
@@ -388,6 +396,15 @@
     <Bug pattern="DMI_RANDOM_USED_ONLY_ONCE"/>
   </Match>
   <Match>
+    <!-- Safer to catch NPE as the root cause of NPEs is not clear -->
+    <Class name="org.apache.catalina.realm.JNDIRealm" />
+    <Or>
+      <Method name="authenticate" />
+      <Method name="getPassword" />
+    </Or>
+    <Bug pattern="DCN_NULLPOINTER_EXCEPTION" />
+  </Match>
+  <Match>
     <!-- roles will be initialized in addAttributeValues -->
     <Class name="org.apache.catalina.realm.JNDIRealm" />
     <Or>
@@ -538,6 +555,12 @@
     <Bug code="OBL" />
   </Match>
   <Match>
+    <!-- There is no null check (SpotBugs bug?) -->
+    <Class name="org.apache.catalina.startup.ContextConfig" />
+    <Method name="populateJavaClassCache" />
+    <Bug pattern="NP_LOAD_OF_KNOWN_NULL_VALUE" />
+  </Match>
+  <Match>
     <!-- Method checks result and logs error later -->
     <Class name="org.apache.catalina.startup.ExpandWar" />
     <Method name="deleteDir" />
@@ -798,6 +821,12 @@
     <Bug code="RCN"/>
   </Match>
   <Match>
+    <!-- There is no null check (SpotBugs bug?) -->
+    <Class name="org.apache.catalina.webresources.AbstractArchiveResource" />
+    <Method name="getContent" />
+    <Bug pattern="NP_LOAD_OF_KNOWN_NULL_VALUE" />
+  </Match>
+  <Match>
     <!-- Array contents is not mutated -->
     <Class name="org.apache.catalina.webresources.CachedResource"/>
     <Or>
@@ -807,6 +836,12 @@
     <Bug pattern="VO_VOLATILE_REFERENCE_TO_ARRAY"/>
   </Match>
   <Match>
+    <!-- Switch fall-though is deliberate -->
+    <Class name="org.apache.coyote.AbstractProcessor"/>
+    <Method name="parseHost"/>
+    <Bug pattern="SF_SWITCH_FALLTHROUGH" />
+  </Match>
+  <Match>
     <!-- Use of synchronisation is required to make a sequence of calls in   -->
     <!-- one method appear to be atomic.                                     -->
     <Class name="org.apache.coyote.AbstractProcessorLight"/>
@@ -942,6 +977,12 @@
     <Bug pattern="DLS_DEAD_LOCAL_STORE"/>
   </Match>
   <Match>
+    <!-- There is no null check (SpotBugs bug?) -->
+    <Class name="org.apache.jasper.compiler.JDTCompiler$1" />
+    <Method name="findType" />
+    <Bug pattern="NP_LOAD_OF_KNOWN_NULL_VALUE" />
+  </Match>
+  <Match>
     <!-- Sync is not protecting these fields -->
     <Class name="org.apache.jasper.compiler.JspConfig"/>
     <Or>
@@ -1033,6 +1074,12 @@
     <Bug code="OBL"/>
   </Match>
   <Match>
+    <!-- There is no null-check -->
+    <Class name="org.apache.juli.FileHandler"/>
+    <Method name="lambda$clean$0" />
+    <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE" />
+  </Match>
+  <Match>
     <!-- If encoding is specified it will be used,
     otherwise platform default encoding will be used -->
     <Class name="org.apache.juli.FileHandler"/>
@@ -1055,7 +1102,12 @@
     <!-- Simpler to catch Exception than to create dummy implementations of the
          necessary exception hierarchy -->
     <Class name="org.apache.naming.factory.SendMailFactory" />
-    <Method name="lambda$0" />
+    <Or>
+      <!-- Latest Eclipse plug-in and latest stand-alone JAR report different
+           method names. -->
+      <Method name="lambda$0" />
+      <Method name="lambda$getObjectInstance$0" />
+    </Or>
     <Bug pattern="DE_MIGHT_IGNORE" />
   </Match>
   <Match>
@@ -1467,6 +1519,12 @@
     <Bug pattern="NO_NOTIFY_NOT_NOTIFYALL " />
   </Match>
   <Match>
+    <!-- NPE should never happen but it is caught as a precaution -->
+    <Class name="org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor" />
+    <Method name="doRun" />
+    <Bug pattern="DCN_NULLPOINTER_EXCEPTION" />
+  </Match>
+  <Match>
     <Class name="org.apache.tomcat.util.net.SecureNioChannel"/>
     <Method name="rehandshake"/>
     <Bug code="DE" />
@@ -1542,6 +1600,17 @@
     <Bug pattern="DMI_RANDOM_USED_ONLY_ONCE"/>
   </Match>
   <Match>
+    <!-- A concurrently closed connection can trigger NPEs. It is not possible
+         to test for this before use. -->
+    <Class name="org.apache.tomcat.websocket.PerMessageDeflate" />
+    <Or>
+      <Method name="getMoreData" />
+      <Method name="sendMessagePart" />
+      <Method name="startNewMessage" />
+    </Or>
+    <Bug pattern="DCN_NULLPOINTER_EXCEPTION" />
+  </Match>
+  <Match>
     <!-- Random will be SecureRandom and will be used multiple times. -->
     <Class name="org.apache.tomcat.websocket.Util"/>
     <Method name="generateMask"/>
@@ -1560,6 +1629,12 @@
     <Bug code="DLS" />
   </Match>
   <Match>
+    <!-- Exception is caught so any issue is handled -->
+    <Class name="org.apache.tomcat.websocket.WsWebSocketContainer" />
+    <Method name="createSSLEngine" />
+    <Bug pattern="REC_CATCH_EXCEPTION" />
+  </Match>
+  <Match>
     <!-- Random will be used multiple times. -->
     <Class name="org.apache.tomcat.websocket.WsWebSocketContainer"/>
     <Method name="generateWsKeyValue"/>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 03/04: Update SpotBugs to 4.5.2

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 29a6511192a35689ac267ad75617edafa120f0f2
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Sat Jan 1 19:30:48 2022 +0000

    Update SpotBugs to 4.5.2
---
 build.properties.default   | 6 +++---
 webapps/docs/changelog.xml | 3 +++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/build.properties.default b/build.properties.default
index 211ed19..96d09f3 100644
--- a/build.properties.default
+++ b/build.properties.default
@@ -282,10 +282,10 @@ jacoco.jar=${jacoco.home}/lib/jacocoant.jar
 jacoco.loc=${base-maven.loc}/org/jacoco/jacoco/${jacoco.version}/jacoco-${jacoco.version}.zip
 
 # ----- SpotBugs (originally FindBugs) -----
-spotbugs.version=4.2.3
+spotbugs.version=4.5.2
 spotbugs.checksum.enabled=true
-spotbugs.checksum.algorithm=MD5|SHA-1
-spotbugs.checksum.value=6eb4a01355a5770f02e136c80182baa6|37daf40c76f11f7ae31894ab8d8fefd7fcb9d07b
+spotbugs.checksum.algorithm=SHA-512
+spotbugs.checksum.value=6e6d4aab1a935f47f9cf4983c30c5c338a257339bd2a6ae4fea2204683d973a67bb95a9204e387ebf9c31070a998367afa12a3b1f812b01f2e27715b704bf194
 spotbugs.home=${base.path}/spotbugs-${spotbugs.version}
 spotbugs.jar=${spotbugs.home}/lib/spotbugs-ant.jar
 spotbugs.loc=${base-maven.loc}/com/github/spotbugs/spotbugs/${spotbugs.version}/spotbugs-${spotbugs.version}.tgz
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index aa83ff9..64f3cd8 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -193,6 +193,9 @@
       <add>
         Improvements to Spanish translations contributed by Israel. (markt)
       </add>
+      <update>
+        Update SpotBugs to 4.5.2. (markt)
+      </update>
     </changelog>
   </subsection>
 </section>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 01/04: FindBugs -> SpotBugs (rename)

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit be99e0405998dbdc6c6bbbb8412c8780a0a64930
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Sat Jan 1 18:59:30 2022 +0000

    FindBugs -> SpotBugs (rename)
---
 BUILDING.txt                                       | 16 +++----
 build.properties.default                           | 18 ++++----
 build.xml                                          | 50 +++++++++++-----------
 .../filter-false-positives.xml                     |  4 +-
 4 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/BUILDING.txt b/BUILDING.txt
index 166ee1f..6ce5ab8 100644
--- a/BUILDING.txt
+++ b/BUILDING.txt
@@ -519,26 +519,26 @@ target. The command is:
     ant -Dexecute.validate=true validate
 
 
-(8.2) FindBugs
+(8.2) SpotBugs
 
-NOTE: FindBugs is licensed under LGPL. Using Findbugs during Tomcat build is
+NOTE: SpotBugs is licensed under LGPL. Using SpotBugs during Tomcat build is
       optional and is off by default.
 
       See https://spotbugs.github.io/ for more information.
 
-To enable FindBugs, add the following property to build.properties file:
+To enable SpotBugs, add the following property to build.properties file:
 
-    execute.findbugs=true
+    execute.spotbugs=true
 
-To compile Tomcat classes and generate a FindBugs report, call the
-"findbugs" target. For example:
+To compile Tomcat classes and generate a SpotBugs report, call the
+"spotbugs" target. For example:
 
     cd ${tomcat.source}
-    ant -Dexecute.findbugs=true findbugs
+    ant -Dexecute.spotbugs=true spotbugs
 
 The report file by default is written to
 
-    output/findbugs
+    output/spotbugs
 
 
 (8.3) End-of-line conventions check
diff --git a/build.properties.default b/build.properties.default
index 66c9d08..211ed19 100644
--- a/build.properties.default
+++ b/build.properties.default
@@ -66,8 +66,8 @@ test.threads=1
 # Enabling code coverage extends the time taken to run the tests by ~50%
 test.coverage=false
 
-# Note the FindBugs is LGPL licensed
-execute.findbugs=false
+# Note the SpotBugs is LGPL licensed
+execute.spotbugs=false
 
 # Some platforms (e.g. OSX El Capitan) require IPv4 to be the default for the
 # multicast tests to work
@@ -282,13 +282,13 @@ jacoco.jar=${jacoco.home}/lib/jacocoant.jar
 jacoco.loc=${base-maven.loc}/org/jacoco/jacoco/${jacoco.version}/jacoco-${jacoco.version}.zip
 
 # ----- SpotBugs (originally FindBugs) -----
-findbugs.version=4.2.3
-findbugs.checksum.enabled=true
-findbugs.checksum.algorithm=MD5|SHA-1
-findbugs.checksum.value=6eb4a01355a5770f02e136c80182baa6|37daf40c76f11f7ae31894ab8d8fefd7fcb9d07b
-findbugs.home=${base.path}/spotbugs-${findbugs.version}
-findbugs.jar=${findbugs.home}/lib/spotbugs-ant.jar
-findbugs.loc=${base-maven.loc}/com/github/spotbugs/spotbugs/${findbugs.version}/spotbugs-${findbugs.version}.tgz
+spotbugs.version=4.2.3
+spotbugs.checksum.enabled=true
+spotbugs.checksum.algorithm=MD5|SHA-1
+spotbugs.checksum.value=6eb4a01355a5770f02e136c80182baa6|37daf40c76f11f7ae31894ab8d8fefd7fcb9d07b
+spotbugs.home=${base.path}/spotbugs-${spotbugs.version}
+spotbugs.jar=${spotbugs.home}/lib/spotbugs-ant.jar
+spotbugs.loc=${base-maven.loc}/com/github/spotbugs/spotbugs/${spotbugs.version}/spotbugs-${spotbugs.version}.tgz
 
 # ----- bnd, version 5.3.0 or later  -----
 # ----- provides OSGI metadata for JARs       -----
diff --git a/build.xml b/build.xml
index dc1260b..dbacea4 100644
--- a/build.xml
+++ b/build.xml
@@ -190,10 +190,10 @@
   <property name="coverage.out" value="${tomcat.output}/coverage"/>
   <property name="coverage.datafile" value="${coverage.out}/jacoco.exec"/>
 
-  <!-- FindBugs settings -->
-  <property name="findbugs.out" value="${tomcat.output}/findbugs"/>
-  <property name="findbugs.report.format" value="html"/>
-  <property name="findbugs.report.level" value="low"/>
+  <!-- SpotBugs settings -->
+  <property name="spotbugs.out" value="${tomcat.output}/spotbugs"/>
+  <property name="spotbugs.report.format" value="html"/>
+  <property name="spotbugs.report.level" value="low"/>
 
   <!-- Workaround against http://bugs.sun.com/view_bug.do?bug_id=6202721 -->
   <available file="/dev/urandom" property="test.jvmarg.egd" value="-Djava.security.egd=file:/dev/./urandom"/>
@@ -2032,23 +2032,23 @@
 
   </target>
 
-  <target name="findbugs"
-          if="${execute.findbugs}"
-          depends="compile,download-findbugs">
+  <target name="spotbugs"
+          if="${execute.spotbugs}"
+          depends="compile,download-spotbugs">
 
-    <path id="findbugs.classpath">
-      <fileset file="${findbugs.jar}" />
+    <path id="spotbugs.classpath">
+      <fileset file="${spotbugs.jar}" />
     </path>
 
-    <taskdef classpathref="findbugs.classpath" name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/>
+    <taskdef classpathref="spotbugs.classpath" name="spotbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/>
 
-    <mkdir dir="${findbugs.out}" />
+    <mkdir dir="${spotbugs.out}" />
 
-    <findbugs home="${findbugs.home}"
-              output="${findbugs.report.format}"
-              outputFile="${findbugs.out}/findbugs-report.${findbugs.report.format}"
-              reportLevel="${findbugs.report.level}"
-              excludeFilter="res/findbugs/filter-false-positives.xml" >
+    <spotbugs home="${spotbugs.home}"
+              output="${spotbugs.report.format}"
+              outputFile="${spotbugs.out}/spotbugs-report.${spotbugs.report.format}"
+              reportLevel="${spotbugs.report.level}"
+              excludeFilter="res/spotbugs/filter-false-positives.xml" >
       <sourcePath path="${basedir}/java" />
       <class location="${tomcat.classes}" />
       <class location="${test.classes}" />
@@ -2056,7 +2056,7 @@
         <fileset file="${jdt.jar}" />
         <fileset file="${ant.core.lib}" />
       </auxClasspath>
-    </findbugs>
+    </spotbugs>
   </target>
 
   <target name="dist-prepare" depends="download-dist">
@@ -3239,16 +3239,16 @@ skip.installer property in build.properties" />
   </target>
 
 
-  <target name="download-findbugs"
-          if="${execute.findbugs}"
-          description="Download FindBugs" >
+  <target name="download-spotbugs"
+          if="${execute.spotbugs}"
+          description="Download SpotBugs" >
 
     <antcall target="downloadgz">
-      <param name="sourcefile" value="${findbugs.loc}"/>
-      <param name="destfile" value="${findbugs.jar}"/>
-      <param name="checksum.enabled" value="${findbugs.checksum.enabled}"/>
-      <param name="checksum.algorithm" value="${findbugs.checksum.algorithm}"/>
-      <param name="checksum.value" value="${findbugs.checksum.value}"/>
+      <param name="sourcefile" value="${spotbugs.loc}"/>
+      <param name="destfile" value="${spotbugs.jar}"/>
+      <param name="checksum.enabled" value="${spotbugs.checksum.enabled}"/>
+      <param name="checksum.algorithm" value="${spotbugs.checksum.algorithm}"/>
+      <param name="checksum.value" value="${spotbugs.checksum.value}"/>
     </antcall>
 
   </target>
diff --git a/res/findbugs/filter-false-positives.xml b/res/spotbugs/filter-false-positives.xml
similarity index 99%
rename from res/findbugs/filter-false-positives.xml
rename to res/spotbugs/filter-false-positives.xml
index 38cc114..5779596 100644
--- a/res/findbugs/filter-false-positives.xml
+++ b/res/spotbugs/filter-false-positives.xml
@@ -15,7 +15,7 @@
   limitations under the License.
 -->
 <FindBugsFilter>
-  <!--  Considered to be false positives -->
+  <!-- Considered to be false positives -->
   <Match>
     <!-- Generated by compiler -->
     <Field name="~\$SWITCH_TABLE\$.*"/>
@@ -1571,7 +1571,7 @@
 
   <!-- Example code -->
   <Match>
-    <!-- FindBugs assumes the container uses the values as is. Tomcat validates
+    <!-- SpotBugs assumes the container uses the values as is. Tomcat validates
          them and escapes them as necessary to ensure they are safe. -->
     <Class name="CookieExample" />
     <Method name="doGet" />

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 02/04: Exclude the SpotBug ranks we (currently) aren't looking at

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit b15e5310db2af31935851fb5c6ebbf8fc9bca6ce
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Sat Jan 1 18:59:54 2022 +0000

    Exclude the SpotBug ranks we (currently) aren't looking at
---
 res/spotbugs/filter-false-positives.xml | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/res/spotbugs/filter-false-positives.xml b/res/spotbugs/filter-false-positives.xml
index 5779596..e29e513 100644
--- a/res/spotbugs/filter-false-positives.xml
+++ b/res/spotbugs/filter-false-positives.xml
@@ -15,6 +15,15 @@
   limitations under the License.
 -->
 <FindBugsFilter>
+  <!-- Exclude the three lowest ranks -->
+  <!-- Remove this exclusion is a long term goal -->
+  <Match>
+    <Or>
+      <Rank value="20" />
+      <Rank value="19" />
+      <Rank value="18" />
+    </Or>
+  </Match>
   <!-- Considered to be false positives -->
   <Match>
     <!-- Generated by compiler -->

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org