This is an automated email from the ASF dual-hosted git repository. remm 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 2fa6bbc81f Handle response committed when processing read error 2fa6bbc81f is described below commit 2fa6bbc81fd090b0563a506db62c94aabbfd29d0 Author: remm <r...@apache.org> AuthorDate: Tue Apr 9 09:58:22 2024 +0200 Handle response committed when processing read error BZ68862 --- java/org/apache/catalina/connector/InputBuffer.java | 16 ++++++++++++++-- webapps/docs/changelog.xml | 4 ++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/java/org/apache/catalina/connector/InputBuffer.java b/java/org/apache/catalina/connector/InputBuffer.java index 3957ec93c2..db85a3415a 100644 --- a/java/org/apache/catalina/connector/InputBuffer.java +++ b/java/org/apache/catalina/connector/InputBuffer.java @@ -316,9 +316,21 @@ public class InputBuffer extends Reader implements ByteChunk.ByteInputChannel, A Response response = request.getResponse(); request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, e); if (e instanceof SocketTimeoutException) { - response.sendError(HttpServletResponse.SC_REQUEST_TIMEOUT); + try { + response.sendError(HttpServletResponse.SC_REQUEST_TIMEOUT); + } catch(IllegalStateException ex) { + // Response already committed + response.setStatus(HttpServletResponse.SC_REQUEST_TIMEOUT); + response.setError(); + } } else { - response.sendError(HttpServletResponse.SC_BAD_REQUEST); + try { + response.sendError(HttpServletResponse.SC_BAD_REQUEST); + } catch(IllegalStateException ex) { + // Response already committed + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + response.setError(); + } } } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index c3708d8d0d..52b61cd0d1 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -147,6 +147,10 @@ file via the Servlet API and the file is larger than <code>Integer.MAX_VALUE</code>. (markt) </fix> + <fix> + <bug>68862</bug>: Handle possible response commit when processing read + errors. (remm) + </fix> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org