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/03/15 17:29:48 UTC

[tomcat] branch main updated (74d1be0 -> e99da3e)

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 74d1be0  Avoid possible NPE
     new 8bef76a  Expand spotbugs Ant task to cover test code
     new 017a5d7  Fix sync issues identified by SpotBugs
     new e99da3e  Add additional false positives for test code

The 3 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:
 build.xml                                          |  2 +-
 res/spotbugs/filter-false-positives.xml            | 19 ++++++++++++++---
 .../catalina/nonblocking/TestNonBlockingAPI.java   |  3 ++-
 .../tribes/test/transport/SocketNioReceive.java    | 24 ++++++++++++++--------
 webapps/docs/changelog.xml                         |  4 ++++
 5 files changed, 38 insertions(+), 14 deletions(-)

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


[tomcat] 03/03: Add additional false positives for test code

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 e99da3e6542f2189b2655ad0781d6a8ac816a26d
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Mar 15 17:18:19 2022 +0000

    Add additional false positives for test code
---
 res/spotbugs/filter-false-positives.xml | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/res/spotbugs/filter-false-positives.xml b/res/spotbugs/filter-false-positives.xml
index c9382b5..85ca2a7 100644
--- a/res/spotbugs/filter-false-positives.xml
+++ b/res/spotbugs/filter-false-positives.xml
@@ -1940,7 +1940,10 @@
   <Match>
     <!-- Return value of latch is intentionally ignored -->
     <Class name="org.apache.catalina.nonblocking.TestNonBlockingAPI"/>
-    <Method name="testDelayedNBWrite"/>
+    <Or>
+      <Method name="testDelayedNBReadWrite"/>
+      <Method name="testDelayedNBWrite"/>
+    </Or>
     <Bug pattern="RV_RETURN_VALUE_IGNORED"/>
   </Match>
   <Match>
@@ -2143,13 +2146,17 @@
     <Bug code="DE" />
   </Match>
   <Match>
-    <!-- Non-constant is just a split constant -->
     <Class name="org.apache.catalina.users.DataSourceUserDatabaseTests"/>
     <Or>
       <Method name="testBasicUserRoleDatabase"/>
       <Method name="testUserDatabase"/>
     </Or>
-    <Bug pattern="SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE"/>
+    <Or>
+      <!-- There is no null check - SpotBugs bug? -->
+      <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/>
+      <!-- Non-constant is just a split constant -->
+      <Bug pattern="SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE"/>
+    </Or>
   </Match>
   <Match>
     <!-- Concrete Map type not affected -->
@@ -2533,4 +2540,10 @@
     </Or>
     <Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT"/>
   </Match>
+  <Match>
+      <!-- There is no null check - SpotBugs bug? -->
+    <Class name="org.apache.tomcat.websocket.server.TestWsServerContainer" />
+    <Method name="testBug58232" />
+    <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/>
+  </Match>
 </FindBugsFilter>

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


[tomcat] 01/03: Expand spotbugs Ant task to cover test code

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 8bef76a877270c4f35bd191036a5611e1b8a6910
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Mar 15 17:17:55 2022 +0000

    Expand spotbugs Ant task to cover test code
---
 build.xml                  | 2 +-
 webapps/docs/changelog.xml | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/build.xml b/build.xml
index 54cd5fd..91282fb 100644
--- a/build.xml
+++ b/build.xml
@@ -2071,7 +2071,7 @@
 
   <target name="spotbugs"
           if="${execute.spotbugs}"
-          depends="compile,download-spotbugs">
+          depends="test-compile,download-spotbugs">
 
     <path id="spotbugs.classpath">
       <fileset file="${spotbugs.jar}" />
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 84b4a5e..01ed9b8 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -133,6 +133,10 @@
       <update>
         Update to SpotBugs 4.6.0. (markt)
       </update>
+      <add>
+        Expand the <code>spotbugs</code> Ant task to also cover test code.
+        (markt)
+      </add>
     </changelog>
   </subsection>
 </section>

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


[tomcat] 02/03: Fix sync issues identified by SpotBugs

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 017a5d73fed304eaeed34be835bc0b886968e9da
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Mar 15 17:18:09 2022 +0000

    Fix sync issues identified by SpotBugs
---
 .../catalina/nonblocking/TestNonBlockingAPI.java   |  3 ++-
 .../tribes/test/transport/SocketNioReceive.java    | 24 ++++++++++++++--------
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
index 0ca63ab..8023e8f 100644
--- a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
+++ b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
@@ -1144,7 +1144,8 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
                     try {
                         byte buffer[] = new byte[1 * 4];
                         while (is.isReady() && !is.isFinished()) {
-                            is.read(buffer);
+                            @SuppressWarnings("unused")
+                            int ignore = is.read(buffer);
                         }
                         String body = new String(buffer, StandardCharsets.UTF_8);
                         Assert.assertTrue(body.equals("body"));
diff --git a/test/org/apache/catalina/tribes/test/transport/SocketNioReceive.java b/test/org/apache/catalina/tribes/test/transport/SocketNioReceive.java
index 763d7b2..9936c63 100644
--- a/test/org/apache/catalina/tribes/test/transport/SocketNioReceive.java
+++ b/test/org/apache/catalina/tribes/test/transport/SocketNioReceive.java
@@ -27,13 +27,15 @@ import org.apache.catalina.tribes.membership.MemberImpl;
 import org.apache.catalina.tribes.transport.nio.NioReceiver;
 
 public class SocketNioReceive {
-    static int count = 0;
-    static int accept = 0;
-    static long start = 0;
-    static double mb = 0;
-    static int len = 0;
-    static DecimalFormat df = new DecimalFormat("##.00");
-    static double seconds = 0;
+    private static int count = 0;
+    private static final Object countLock = new Object();
+    private static int accept = 0;
+    private static final Object acceptLock = new Object();
+    private static long start = 0;
+    private static double mb = 0;
+    private static int len = 0;
+    private static DecimalFormat df = new DecimalFormat("##.00");
+    private static double seconds = 0;
 
     protected static final Object mutex = new Object();
     public static void main(String[] args) throws Exception {
@@ -74,7 +76,9 @@ public class SocketNioReceive {
                 start = System.currentTimeMillis();
             }
             mb += ( (double) len) / 1024 / 1024;
-            synchronized (this) {count++;}
+            synchronized (countLock) {
+                count++;
+            }
             if ( ( (count) % 10000) == 0) {
                 long time = System.currentTimeMillis();
                 seconds = ( (double) (time - start)) / 1000;
@@ -84,7 +88,9 @@ public class SocketNioReceive {
 
         @Override
         public boolean accept(ChannelMessage msg) {
-            synchronized (this) {accept++;}
+            synchronized (acceptLock) {
+                accept++;
+            }
             return true;
         }
 

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