This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 278b50a Add low effort null check in facade
278b50a is described below
commit 278b50ae985ce87a3c8da51de054e6db56dd4ced
Author: remm <[email protected]>
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 c7ee2e9..e1f14f5 100644
--- a/java/org/apache/catalina/connector/CoyoteInputStream.java
+++ b/java/org/apache/catalina/connector/CoyoteInputStream.java
@@ -198,6 +198,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 98ec857..c76e757 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 f64b3b6..d16831d 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -111,6 +111,10 @@
Add additional locking to <code>DataSourceUserDatabase</code> to
provide
improved protection for concurrent modifications. (markt)
</fix>
+ <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: [email protected]
For additional commands, e-mail: [email protected]