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

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

commit 7837e6f798190316d40c7ebf1efeb3a241efa090
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Aug 27 13:52:44 2020 +0100

    Avoid NPE observed in CI
---
 java/org/apache/coyote/http2/Stream.java | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/http2/Stream.java
index 8b2b0d2..ea87346 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -300,14 +300,19 @@ class Stream extends AbstractStream implements 
HeaderEmitter {
 
 
     void doStreamCancel(String msg, Http2Error error) throws CloseNowException 
{
+        // Avoid NPEs on duplicate cancellations
+        StreamOutputBuffer streamOutputBuffer = this.streamOutputBuffer;
+        Response coyoteResponse = this.coyoteResponse;
         StreamException se = new StreamException(msg, error, getIdAsInt());
-        // Prevent the application making further writes
-        streamOutputBuffer.closed = true;
-        // Prevent Tomcat's error handling trying to write
-        coyoteResponse.setError();
-        coyoteResponse.setErrorReported();
-        // Trigger a reset once control returns to Tomcat
-        streamOutputBuffer.reset = se;
+        if (streamOutputBuffer != null && coyoteResponse != null) {
+            // Prevent the application making further writes
+            streamOutputBuffer.closed = true;
+            // Prevent Tomcat's error handling trying to write
+            coyoteResponse.setError();
+            coyoteResponse.setErrorReported();
+            // Trigger a reset once control returns to Tomcat
+            streamOutputBuffer.reset = se;
+        }
         throw new CloseNowException(msg, se);
     }
 


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

Reply via email to