Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #4603 - avoid NPE during websocket HTTP/2 upgrade #4702

Merged
merged 2 commits into from
Mar 26, 2020

Conversation

lachlan-roberts
Copy link
Contributor

Issue #4603

If no UPGRADE_CONNECTION_ATTRIBUTE is set when prepareUpgrade() is called we should do a sendErrorOrAbort on the channel.

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
@lachlan-roberts
Copy link
Contributor Author

After these changes I no longer get the NPE reported in #4603, however I occasionally get a RejectedExecutionException from WebSocketOverHTTP2Test.testThrowFromCreator(), this only occurs rarely when running the test and I am not sure if it is related to these changes. I could not reproduce with debug enabled.

2020-03-24 14:55:57.353:INFO :oejs.Server:main: jetty-10.0.0-SNAPSHOT; built: unknown; git: ; jvm 11.0.5+10-LTS
2020-03-24 14:55:57.421:INFO :oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@51549490{/,null,AVAILABLE}
2020-03-24 14:55:57.424:INFO :oejs.AbstractConnector:main: Started ServerConnector@4b213651{HTTP/1.1, (http/1.1, h2c)}{0.0.0.0:39139}
2020-03-24 14:55:57.433:INFO :oejus.SslContextFactory:main: x509=X509@36a5cabc(1,h=[],w=[]) for Server@432038ec[provider=null,keyStore=file:///home/lachlan/webtide/src/jetty-10.0.x/jetty-websocket/websocket-jetty-tests/src/test/resources/keystore.p12,trustStore=null]
2020-03-24 14:55:57.469:INFO :oejs.AbstractConnector:main: Started ServerConnector@60410cd{SSL, (ssl, alpn, http/1.1, h2)}{0.0.0.0:34507}
2020-03-24 14:55:57.471:INFO :oejs.Server:main: Started Server@babafc2{STARTING}[10.0.0-SNAPSHOT,sto=0] @2848ms
2020-03-24 14:55:57.477:WARN :oejusS.config:main: Trusting all certificates configured for Client@35645047[provider=null,keyStore=null,trustStore=null]
2020-03-24 14:55:57.478:WARN :oejusS.config:main: No Client EndPointIdentificationAlgorithm configured for Client@35645047[provider=null,keyStore=null,trustStore=null]
2020-03-24 14:55:57.604:WARN :oejs.HttpChannel:server-33: /ws/throw: java.lang.RuntimeException: throwing from creator
2020-03-24 14:55:57.611:INFO :oejs.Server:main: Stopped Server@babafc2{STOPPING}[10.0.0-SNAPSHOT,sto=0]
2020-03-24 14:55:57.623:INFO :oejs.AbstractConnector:main: Stopped ServerConnector@4b213651{HTTP/1.1, (http/1.1, h2c)}{0.0.0.0:0}
2020-03-24 14:55:57.629:INFO :oejs.AbstractConnector:main: Stopped ServerConnector@60410cd{SSL, (ssl, alpn, http/1.1, h2)}{0.0.0.0:0}
2020-03-24 14:55:57.630:INFO :oejsh.ContextHandler:main: Stopped o.e.j.s.ServletContextHandler@51549490{/,null,UNAVAILABLE}
2020-03-24 14:55:57.639:INFO :oejh.HTTP2Session:server-33: Failure while notifying listener org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory$HTTPServerSessionListener@16a6ee1e
java.util.concurrent.RejectedExecutionException: EatWhatYouKill@7adda998/HTTP2Producer@7302c83a/IDLE/p=true/QueuedThreadPool[server]@51133c06{STOPPING,8<=0<=200,i=4,r=-1,q=0}[NO_TRY][pc=0,pic=0,pec=0,epc=1]@2020-03-24T14:55:57.636969+11:00
	at org.eclipse.jetty.util.thread.QueuedThreadPool.execute(QueuedThreadPool.java:526)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.dispatch(EatWhatYouKill.java:123)
	at org.eclipse.jetty.http2.HTTP2Connection.dispatch(HTTP2Connection.java:211)
	at org.eclipse.jetty.http2.HTTP2Connection.offerTask(HTTP2Connection.java:187)
	at org.eclipse.jetty.http2.server.HTTP2ServerConnection.onStreamFailure(HTTP2ServerConnection.java:217)
	at org.eclipse.jetty.http2.server.HTTP2ServerConnection.onSessionFailure(HTTP2ServerConnection.java:255)
	at org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory$HTTPServerSessionListener.onFailure(HTTP2ServerConnectionFactory.java:143)
	at org.eclipse.jetty.http2.HTTP2Session.notifyFailure(HTTP2Session.java:1230)
	at org.eclipse.jetty.http2.HTTP2Session.abort(HTTP2Session.java:1134)
	at org.eclipse.jetty.http2.HTTP2Flusher.onCompleteFailure(HTTP2Flusher.java:344)
	at org.eclipse.jetty.util.IteratingCallback.failed(IteratingCallback.java:391)
	at org.eclipse.jetty.io.WriteFlusher.write(WriteFlusher.java:302)
	at org.eclipse.jetty.io.AbstractEndPoint.write(AbstractEndPoint.java:391)
	at org.eclipse.jetty.http2.HTTP2Flusher.process(HTTP2Flusher.java:259)
	at org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:237)
	at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:219)
	at org.eclipse.jetty.http2.HTTP2Session.frame(HTTP2Session.java:784)
	at org.eclipse.jetty.http2.HTTP2Session.frames(HTTP2Session.java:754)
	at org.eclipse.jetty.http2.HTTP2Stream.headers(HTTP2Stream.java:125)
	at org.eclipse.jetty.http2.server.HttpTransportOverHTTP2.sendHeadersFrame(HttpTransportOverHTTP2.java:280)
	at org.eclipse.jetty.http2.server.HttpTransportOverHTTP2.send(HttpTransportOverHTTP2.java:161)
	at org.eclipse.jetty.server.HttpChannel.sendResponse(HttpChannel.java:850)
	at org.eclipse.jetty.server.HttpChannel.sendResponseAndComplete(HttpChannel.java:639)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:409)
	at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:327)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:135)
	at org.eclipse.jetty.http2.HTTP2Connection.produce(HTTP2Connection.java:204)
	at org.eclipse.jetty.http2.HTTP2Connection.onFillable(HTTP2Connection.java:151)
	at org.eclipse.jetty.http2.HTTP2Connection$FillableCallback.succeeded(HTTP2Connection.java:374)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:135)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:823)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:945)
	at java.base/java.lang.Thread.run(Thread.java:834)

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
@lachlan-roberts
Copy link
Contributor Author

@sbordet can I get a review

@lachlan-roberts
Copy link
Contributor Author

The RejectedExecutionException was also fixed by waiting for request onComplete before shutting down the server in WebSocketOverHTTP2Test.testThrowFromCreator().

@lachlan-roberts lachlan-roberts merged commit d595c59 into jetty-10.0.x Mar 26, 2020
@lachlan-roberts lachlan-roberts deleted the jetty-10.0.x-4603-WS_HTTP2_NPE branch March 26, 2020 22:44
@lachlan-roberts lachlan-roberts linked an issue Mar 26, 2020 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate WebSocketOverHTTP2Test.testServerConnectionClose()
3 participants