Skip to content

Commit

Permalink
Fix for #367 IllegalStateException: No SessionManager even when PROPE…
Browse files Browse the repository at this point in the history
…RTY_SESSION_SUPPORT set to false
  • Loading branch information
jfarcand committed May 18, 2012
1 parent ba1ff6f commit cde6fd1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.atmosphere.jetty;

import org.atmosphere.cpr.ApplicationConfig;
import org.atmosphere.cpr.AtmosphereFramework;
import org.atmosphere.cpr.AtmosphereRequest;
import org.atmosphere.cpr.AtmosphereResponse;
Expand Down Expand Up @@ -184,6 +185,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse res)
public org.eclipse.jetty.websocket.WebSocket doWebSocketConnect(final HttpServletRequest request, final String protocol) {
logger.debug("WebSocket upgrade requested");
request.setAttribute(WebSocket.WEBSOCKET_INITIATED, true);
return new JettyWebSocketDraft08Handler(AtmosphereRequest.loadInMemory(request, false), framework, framework.getWebSocketProtocol());
return new JettyWebSocketDraft08Handler(AtmosphereRequest.cloneRequest(request, false,
framework().getAtmosphereConfig().isSupportSession()), framework, framework.getWebSocketProtocol());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public boolean checkOrigin(HttpServletRequest request, String origin) {

public org.eclipse.jetty.websocket.WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
logger.trace("WebSocket-connect request {} with protocol {}", request.getRequestURI(), protocol);
return new JettyWebSocketHandler(AtmosphereRequest.loadInMemory(request, false), config.framework(), config.framework().getWebSocketProtocol());
return new JettyWebSocketHandler(AtmosphereRequest.cloneRequest(request, false, config.isSupportSession()), config.framework(), config.framework().getWebSocketProtocol());
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static Action doService(AtmosphereRequest req, AtmosphereResponse res,
hsr = (HttpServletRequest) ((HttpServletRequestWrapper) hsr).getRequest();

RequestFacade facade = (RequestFacade) hsr;
StreamInbound inbound = new TomcatWebSocketHandler(AtmosphereRequest.loadInMemory(req, true),
StreamInbound inbound = new TomcatWebSocketHandler(AtmosphereRequest.cloneRequest(req, true, config.isSupportSession()),
config.framework(), config.framework().getWebSocketProtocol());
facade.doUpgrade(inbound);
return new Action(Action.TYPE.CREATED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ public final static AtmosphereRequest wrap(HttpServletRequest request) {
* @param request {@link HttpServletRequest}
* @return an {@link AtmosphereRequest}
*/
public final static AtmosphereRequest loadInMemory(HttpServletRequest request, boolean loadInMemory) {
public final static AtmosphereRequest cloneRequest(HttpServletRequest request, boolean loadInMemory, boolean copySession) {
Builder b;
HttpServletRequest r;
boolean isWrapped = false;
Expand All @@ -1470,7 +1470,7 @@ public final static AtmosphereRequest loadInMemory(HttpServletRequest request, b
.serverName(request.getServerName())
.serverPort(request.getServerPort())
.destroyable(false)
.session(new FakeHttpSession(request.getSession(true)));
.session(copySession? new FakeHttpSession(request.getSession(true)) : null);

if (loadInMemory) {
r = new NoOpsRequest();
Expand Down

0 comments on commit cde6fd1

Please sign in to comment.