Community
Participate
Working Groups
From Jeanfrancois Arcand: Before 8.0.1, I was able to continue using the HttpServletRequest after the WebSocket handshake. That allowed me to run Jersey on top of Jetty WebSocket. Starting in 8.0.2, the HttpServletRequest and its associated Request gets recycled, producing NPE Here's the link to the Atmosphere issue: https://github.com/Atmosphere/atmosphere/issues/45
The test case is here: https://github.com/Atmosphere/Incubator/blob/master/atmosphere-jquery-pubsub-RequestRecycled.war Rename to atmosphere-jquery-pubsub.war Deploy in 8.0.2 and up (8.0.1 works fine) (1) Enter a topic (2) connect All kind of NPEs will be displayed, caused because the Request was recycled Caused by: java.lang.NullPointerException at org.eclipse.jetty.server.Request.getServerName(Request.java:1008) at org.eclipse.jetty.server.Request.getServerPort(Request.java:1071) at org.eclipse.jetty.server.Request.getRequestURL(Request.java:934) at javax.servlet.http.HttpServletRequestWrapper.getRequestURL(HttpServletRequestWrapper.java:241) at javax.servlet.http.HttpServletRequestWrapper.getRequestURL(HttpServletRequestWrapper.java:241) at org.atmosphere.cpr.AtmosphereRequest.getRequestURL(AtmosphereRequest.java:105) at javax.servlet.http.HttpServletRequestWrapper.getRequestURL(HttpServletRequestWrapper.java:241) at org.atmosphere.cpr.AtmosphereRequest.getRequestURL(AtmosphereRequest.java:105) at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:638) at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) at org.atmosphere.util.AtmosphereFilterChain.doFilter(AtmosphereFilterChain.java:155) at org.atmosphere.util.AtmosphereFilterChain.invokeFilterChain(AtmosphereFilterChain.java:116) at org.atmosphere.handler.ReflectorServletProcessor$FilterChainServletWrapper.service(ReflectorServletProcessor.java:293) at org.atmosphere.handler.ReflectorServletProcessor.onRequest(ReflectorServletProcessor.java:151) at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:214) at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:149) at org.atmosphere.container.Jetty7CometSupport.service(Jetty7CometSupport.java:82) at org.atmosphere.container.JettyCometSupportWithWebSocket.service(JettyCometSupportWithWebSocket.java:85) at org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:1179) at org.atmosphere.websocket.WebSocketProcessor.dispatch(WebSocketProcessor.java:144)
Hi Jeanfrancois, I've taken a look at your code, the jetty code, and consulted with Greg. I think the atmosphere code is suspending on the request that initiates websocket. The next input that comes in over the websocket connection is then used to wake up the suspended request. However, after websocket is established, and the 101 response has gone back, we throw away (ie recycle) the Request and Response as they have no further relevance, as the connection is now speaking websocket. Greg recommends that you do not suspend on the request that establishes websocket, as the request/response cycle is supposed to be finished when websocket is established. I will add NPE protection in the Request in any case. regards Jan
The Request.getServerName method throws IllegalStateException if the uri is null. Checked into jetty-7 and will be incorporated into jetty-8 next release.