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
The following commit(s) were added to refs/heads/main by this push: new 6d74989 Fix concurrency issues reported by SpotBugs 6d74989 is described below commit 6d7498934c5cac14bc6bfc549d15bd2496275356 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/jakarta/servlet/http/TestHttpServletDoHead.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/jakarta/servlet/http/TestHttpServletDoHead.java b/test/jakarta/servlet/http/TestHttpServletDoHead.java index 006c560..31f4b91 100644 --- a/test/jakarta/servlet/http/TestHttpServletDoHead.java +++ b/test/jakarta/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