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

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


The following commit(s) were added to refs/heads/8.5.x by this push:
     new 6a34a9e  Fix concurrency issues reported by SpotBugs
6a34a9e is described below

commit 6a34a9ecf178948cacff391e9cd64efa4638bb44
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Jun 23 17:06:25 2021 +0100

    Fix concurrency issues reported by SpotBugs
    
    Tests not affected as they don't generate concurrent requests to this
    servlet but fix the concurrency issues anyway.
---
 test/javax/servlet/http/TestHttpServletDoHead.java | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/test/javax/servlet/http/TestHttpServletDoHead.java 
b/test/javax/servlet/http/TestHttpServletDoHead.java
index 49105a0..74bff5d 100644
--- a/test/javax/servlet/http/TestHttpServletDoHead.java
+++ b/test/javax/servlet/http/TestHttpServletDoHead.java
@@ -144,9 +144,6 @@ public class TestHttpServletDoHead extends TomcatBaseTest {
         private final int validWriteCount;
         private final boolean explicitFlush;
 
-        private PrintWriter pw = null;
-        private OutputStream os = null;
-
         public HeadTestServlet(int bufferSize, boolean useWriter, int 
invalidWriteCount, ResetType resetType,
                 int validWriteCount, boolean explicitFlush) {
             this.bufferSize = bufferSize;
@@ -164,6 +161,8 @@ public class TestHttpServletDoHead extends TomcatBaseTest {
             resp.setContentType("text/plain");
             resp.setCharacterEncoding("UTF-8");
 
+            PrintWriter pw = null;
+            OutputStream os = null;
             // Do this rather than repeated calls to getWriter() /
             // getOutputStream() to ensure that HEAD handling doesn't rely on
             // replacing the OutputStream / PrintWriter (an earlier
@@ -175,7 +174,7 @@ public class TestHttpServletDoHead extends TomcatBaseTest {
             }
 
             for (int i = 0; i < invalidWriteCount; i++) {
-                write(INVALID);
+                write(INVALID, pw, os);
             }
 
             try {
@@ -193,11 +192,11 @@ public class TestHttpServletDoHead extends TomcatBaseTest 
{
                     }
                 }
             } catch (IllegalStateException ise) {
-                write("\nIllegalStateException\n");
+                write("\nIllegalStateException\n", pw, os);
             }
 
             for (int i = 0; i < validWriteCount; i++) {
-                write(VALID);
+                write(VALID, pw, os);
             }
 
             if (explicitFlush) {
@@ -205,7 +204,7 @@ public class TestHttpServletDoHead extends TomcatBaseTest {
             }
         }
 
-        private void write(String msg) throws IOException {
+        private void write(String msg, PrintWriter pw, OutputStream os) throws 
IOException {
             if (useWriter) {
                 pw.print(msg);
             } else {

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

Reply via email to