This is an automated email from the ASF dual-hosted git repository. remm 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 2113d6b Add low effort null check in facade 2113d6b is described below commit 2113d6beaf9ba56b3d4bca87d80ed512d4c26e7c Author: remm <r...@apache.org> AuthorDate: Wed Jan 5 13:23:04 2022 +0100 Add low effort null check in facade isReady is a likely target for uncontrolled async access, so add a check for null there to throw a more informative ISE if possible, like is done in Request/ResponseFacade for the most common calls. As seen in BZ65780 (when faced with a NPE, users always assume it is a Tomcat bug) --- java/org/apache/catalina/connector/CoyoteInputStream.java | 3 +++ java/org/apache/catalina/connector/CoyoteOutputStream.java | 3 +++ java/org/apache/catalina/connector/LocalStrings.properties | 2 ++ webapps/docs/changelog.xml | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/java/org/apache/catalina/connector/CoyoteInputStream.java b/java/org/apache/catalina/connector/CoyoteInputStream.java index 8e47c53..9e9c4bf 100644 --- a/java/org/apache/catalina/connector/CoyoteInputStream.java +++ b/java/org/apache/catalina/connector/CoyoteInputStream.java @@ -241,6 +241,9 @@ public class CoyoteInputStream extends ServletInputStream { @Override public boolean isReady() { + if (ib == null) { + throw new IllegalStateException(sm.getString("coyoteInputStream.null")); + } return ib.isReady(); } diff --git a/java/org/apache/catalina/connector/CoyoteOutputStream.java b/java/org/apache/catalina/connector/CoyoteOutputStream.java index cf27525..3c470dc 100644 --- a/java/org/apache/catalina/connector/CoyoteOutputStream.java +++ b/java/org/apache/catalina/connector/CoyoteOutputStream.java @@ -159,6 +159,9 @@ public class CoyoteOutputStream extends ServletOutputStream { @Override public boolean isReady() { + if (ob == null) { + throw new IllegalStateException(sm.getString("coyoteOutputStream.null")); + } return ob.isReady(); } diff --git a/java/org/apache/catalina/connector/LocalStrings.properties b/java/org/apache/catalina/connector/LocalStrings.properties index eea0161..278aed0 100644 --- a/java/org/apache/catalina/connector/LocalStrings.properties +++ b/java/org/apache/catalina/connector/LocalStrings.properties @@ -37,8 +37,10 @@ coyoteConnector.protocolHandlerStartFailed=Protocol handler start failed coyoteConnector.protocolHandlerStopFailed=Protocol handler stop failed coyoteInputStream.nbNotready=In non-blocking mode you may not read from the ServletInputStream until the previous read has completed and isReady() returns true +coyoteInputStream.null=The input buffer object has been recycled and is no longer associated with this facade coyoteOutputStream.nbNotready=In non-blocking mode you may not write to the ServletOutputStream until the previous write has completed and isReady() returns true +coyoteOutputStream.null=The output buffer object has been recycled and is no longer associated with this facade coyoteRequest.alreadyAuthenticated=This request has already been authenticated coyoteRequest.attributeEvent=Exception thrown by attributes event listener diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 0067fbd..27dd687 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -138,6 +138,10 @@ does not explicitly close an input stream for an uploaded file that was cached on disk. (markt) </add> + <fix> + Add recycling check in the input and output stream isReady to try to + give a more informative ISE when the facade has been recycled. (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