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:37:59 UTC

[tomcat] branch 10.0.x updated (b0f2793 -> 011b5a7)

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

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


    from b0f2793  Avoid possible NPE
     new 816d250  Expand spotbugs Ant task to cover test code
     new 011b5a7  Fix sync issues identified by SpotBugs

The 2 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 +-
 .../catalina/nonblocking/TestNonBlockingAPI.java   |  3 ++-
 .../tribes/test/transport/SocketNioReceive.java    | 24 ++++++++++++++--------
 webapps/docs/changelog.xml                         |  4 ++++
 4 files changed, 22 insertions(+), 11 deletions(-)

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


[tomcat] 01/02: 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 10.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 816d2509a0737555a1e4f97d09029f8a6c9921f4
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 cb0e971..a108130 100644
--- a/build.xml
+++ b/build.xml
@@ -2033,7 +2033,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 70b950d..f538566 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/02: 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 10.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 011b5a7efad69bbaefe79464a3d55d69bb856030
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