This is an automated email from the ASF dual-hosted git repository.
markt 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 07777cf Avoid potential NPEs introduced in smaller footprint for
closed streams
07777cf is described below
commit 07777cf3514c3dee16e35473946fad82a340f64f
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Aug 12 18:12:43 2020 +0100
Avoid potential NPEs introduced in smaller footprint for closed streams
---
java/org/apache/coyote/http2/Stream.java | 10 ++++++++++
webapps/docs/changelog.xml | 4 ++++
2 files changed, 14 insertions(+)
diff --git a/java/org/apache/coyote/http2/Stream.java
b/java/org/apache/coyote/http2/Stream.java
index 45fc82a..0371be9 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -548,6 +548,11 @@ public class Stream extends AbstractStream implements
HeaderEmitter {
ByteBuffer getInputByteBuffer() {
+ // Avoid NPE if Stream has been closed on Stream specific thread
+ StreamInputBuffer inputBuffer = this.inputBuffer;
+ if (inputBuffer == null) {
+ return null;
+ }
return inputBuffer.getInBuffer();
}
@@ -576,6 +581,11 @@ public class Stream extends AbstractStream implements
HeaderEmitter {
final void receivedData(int payloadSize) throws ConnectionException {
contentLengthReceived += payloadSize;
+ Request coyoteRequest = this.coyoteRequest;
+ // Avoid NPE if Stream has been closed on Stream specific thread
+ if (coyoteRequest == null) {
+ return;
+ }
long contentLengthHeader = coyoteRequest.getContentLengthLong();
if (contentLengthHeader > -1 && contentLengthReceived >
contentLengthHeader) {
throw new
ConnectionException(sm.getString("stream.header.contentLength",
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index db9d5a0..7c630ef 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -85,6 +85,10 @@
<code>ServletInputStream.available()</code> to provide a more accurate
return value, particularly when end of stream has been reached. (markt)
</fix>
+ <fix>
+ Avoid several potential NPEs introduced in the changes in the previous
+ release to reduce the memory footprint of closed HTTP/2 streams.
(markt)
+ </fix>
</changelog>
</subsection>
<subsection name="WebSocket">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]