Bug 61719 - http2(h2) AsyncContext setReadListener NullPointerException
Summary: http2(h2) AsyncContext setReadListener NullPointerException
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Connectors (show other bugs)
Version: 9.0.1
Hardware: PC Linux
: P2 major (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2017-11-03 14:28 UTC by Jack
Modified: 2017-11-03 15:35 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Jack 2017-11-03 14:28:19 UTC
With http2 enabled(h2 with https), after AsyncContext started,

ServletInputStream sis = request.getInputStream();
  sis.setReadListener(this);  //this line throw exception

	at org.apache.coyote.http2.Stream$StreamInputBuffer.registerReadInterest(Stream.java:920)
	at org.apache.coyote.http2.StreamProcessor.registerReadInterest(StreamProcessor.java:176)
	at org.apache.coyote.AbstractProcessor.action(AbstractProcessor.java:453)
	at org.apache.coyote.Request.action(Request.java:430)
	at org.apache.catalina.connector.InputBuffer.isReady(InputBuffer.java:287)
	at org.apache.catalina.connector.InputBuffer.setReadListener(InputBuffer.java:243)
	at org.apache.catalina.connector.CoyoteInputStream.setReadListener(CoyoteInputStream.java:207)

If the post data as query string, then no problem.
but if the post data as http request body, then I got the above exception.
Comment 1 Jack 2017-11-03 14:31:26 UTC
By the way,  the code is in a AsyncContextHandler

ServletInputStream sis = request.getInputStream();
  sis.setReadListener(this);  //this line throw exception, this is the ACHandler

any way, this will never be null, it has nothing to do with this. And it is easy to see in Stream.java.
Comment 2 Remy Maucherat 2017-11-03 14:40:51 UTC
Fixed in 9.0.2. I don't know if there's a root cause that needs to be fixed.
Comment 3 Jack 2017-11-03 15:12:28 UTC
By the way, If I remove

        <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />

from the https connector then I will not got this NullPointerException.

Good to know, you people have already fixed it. Great.
Comment 4 Jack 2017-11-03 15:15:34 UTC
9.0.1 is still in beta, where can I download the 9.0.2 in alpha or something?
Comment 5 Remy Maucherat 2017-11-03 15:35:23 UTC
The fix will be included in 9.0.2 and 8.5.24.