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

Missing handshake session leads to NPE in Jetty #2505

Closed
ddworak opened this issue Apr 11, 2024 · 2 comments
Closed

Missing handshake session leads to NPE in Jetty #2505

ddworak opened this issue Apr 11, 2024 · 2 comments
Assignees
Labels

Comments

@ddworak
Copy link

ddworak commented Apr 11, 2024

Describe the bug
After upgrading from Atmosphere 2.7.11 to Atmosphere 2.7.13, new connections started failing with NPEs on our Jetty 10 JSR356 backend:

16:01:52.946 [qtp661047965-19] ERROR o.a.container.JSR356Endpoint - 
java.lang.NullPointerException: Cannot invoke "javax.servlet.http.HttpSession.getAttributeNames()" because "this.handshakeSession" is null
	at org.atmosphere.container.JSR356Endpoint.onOpen(JSR356Endpoint.java:229)
	at org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandler.onOpen(JavaxWebSocketFrameHandler.java:176)
	at org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession.lambda$onOpen$6(WebSocketCoreSession.java:411)
	at org.eclipse.jetty.server.handler.ContextHandler.handle(ContextHandler.java:1469)
	at org.eclipse.jetty.server.handler.ContextHandler.handle(ContextHandler.java:1488)
	at org.eclipse.jetty.websocket.core.server.internal.AbstractHandshaker$1.handle(AbstractHandshaker.java:212)
	at org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession.onOpen(WebSocketCoreSession.java:411)
	at org.eclipse.jetty.websocket.core.internal.WebSocketConnection.onOpen(WebSocketConnection.java:551)
	at org.eclipse.jetty.io.AbstractEndPoint.upgrade(AbstractEndPoint.java:451)
	at org.eclipse.jetty.server.HttpConnection.upgrade(HttpConnection.java:424)
	at org.eclipse.jetty.server.HttpConnection.onCompleted(HttpConnection.java:455)
	at org.eclipse.jetty.server.HttpChannel.onCompleted(HttpChannel.java:959)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:489)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:287)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:314)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
	at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:421)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:390)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:277)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.produce(AdaptiveExecutionStrategy.java:193)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:969)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1194)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1149)
	at java.base/java.lang.Thread.run(Thread.java:840)

I believe this was introduced in #2504, which assumes that the session is not null. The javax.websocket.server.HandshakeRequest#getHttpSession docs provide null as a valid implementation when running outside of a Java EE container.

Atmosphere Info

  • 2.7.13
  • 3.1.3
  • extensions used: none

Expected behavior
Continue working without unavailable handshake session headers.

Systems (please complete the following information):

  • Java 17
  • Jetty 10.0.20

Additional context
UdashFramework/udash-core#1212

@jfarcand
Copy link
Member

@ddworak On it!

jfarcand added a commit that referenced this issue Apr 11, 2024
jfarcand added a commit that referenced this issue Apr 11, 2024
@ddworak
Copy link
Author

ddworak commented Apr 11, 2024

Thanks a lot @jfarcand! 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants