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

NPE in JsrSession when dealing with a response missing the Sec-WebSocket-Extensions header #1202

Closed
philwebb opened this issue Dec 23, 2016 · 1 comment
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@philwebb
Copy link

Using the JSR WebSocket client provided in Jetty 9.4.0.v20161208 the following NPE can be thrown:

java.lang.NullPointerException: null
	at org.eclipse.jetty.websocket.jsr356.JsrSession.getNegotiatedExtensions(JsrSession.java:247)
	at org.springframework.web.socket.adapter.standard.StandardWebSocketSession.initializeNativeSession(StandardWebSocketSession.java:184)
	at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.onOpen(StandardWebSocketHandlerAdapter.java:61)
	at org.eclipse.jetty.websocket.jsr356.endpoints.JsrEndpointEventDriver.onConnect(JsrEndpointEventDriver.java:140)
	at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.openSession(AbstractEventDriver.java:233)
	at org.eclipse.jetty.websocket.jsr356.endpoints.AbstractJsrEventDriver.openSession(AbstractJsrEventDriver.java:104)
	at org.eclipse.jetty.websocket.common.WebSocketSession.open(WebSocketSession.java:504)
	at org.eclipse.jetty.websocket.common.WebSocketSession.onOpened(WebSocketSession.java:433)
	at org.eclipse.jetty.io.AbstractConnection.onOpen(AbstractConnection.java:200)
	at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.onOpen(AbstractWebSocketConnection.java:566)
	at org.eclipse.jetty.io.AbstractEndPoint.upgrade(AbstractEndPoint.java:432)
	at org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.upgrade(WebSocketUpgradeRequest.java:622)
	at org.eclipse.jetty.client.http.HttpChannelOverHTTP.exchangeTerminating(HttpChannelOverHTTP.java:116)
	at org.eclipse.jetty.client.HttpReceiver.terminateResponse(HttpReceiver.java:451)
	at org.eclipse.jetty.client.HttpReceiver.responseSuccess(HttpReceiver.java:405)
	at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.messageComplete(HttpReceiverOverHTTP.java:281)
	at org.eclipse.jetty.http.HttpParser.parseHeaders(HttpParser.java:1071)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1320)
	at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.parse(HttpReceiverOverHTTP.java:170)
	at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:131)
	at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:70)
	at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:130)
	at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:116)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:112)
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
	at java.lang.Thread.run(Thread.java:745)

This happens if the ClientUpgradeResponse does not contain a Sec-WebSocket-Extensions header.

I believe that commit e0d3536 may have changed the behavior of ClientUpgradeResponse (specifically around these lines) meaning that getExtensions() now returns null rather than an empty list.

philwebb added a commit to spring-projects/spring-boot that referenced this issue Dec 24, 2016
Add workaround for Jetty JsrSession NullPointerException bug
(jetty/jetty.project#1202) in
`spring-boot-sample-websocket-jetty`.

See gh-7599
philwebb added a commit to spring-projects/spring-boot that referenced this issue Dec 24, 2016
Move samples and tests from Jetty websocket client to Tomcat since the
upcoming Jetty release contains a bug in `JsrSession`
(jetty/jetty.project#1202).

See gh-7599
@joakime joakime self-assigned this Dec 27, 2016
@joakime joakime added the Bug For general bugs on Jetty side label Dec 27, 2016
@joakime
Copy link
Contributor

joakime commented Dec 27, 2016

Closing as fixed with commit bf80d82

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

No branches or pull requests

2 participants