From f697509af0fe79939cd781ebad65e1410e1b334e Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 18 Mar 2010 11:08:40 +0000 Subject: [PATCH] 306331 Session manager is kept after call to doScope git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1388 7e9141cc-0065-0410-87d8-b60c137991c4 --- VERSION.txt | 1 + .../org/eclipse/jetty/server/Request.java | 1 + .../session/AbstractSessionManager.java | 47 ++++++++----------- .../jetty/server/session/SessionHandler.java | 15 +++--- .../jetty/server/AsyncContextTest.java | 10 +++- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index cf5a010484b..47779388cce 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -30,6 +30,7 @@ jetty-7.0.2.RC0 + 304698 org.eclipse.jetty.http.HttpFields$DateGenerator.formatCookieDate() uses wrong (?) date format + 304781 Reset HttpExchange timeout on slow request content. + 304801 SSL connections FULL fix + + 306331 Session manager is kept after call to doScope + JETTY-776 Make new session-tests module to concentrate all reusable session clustering test code + JETTY-910 Allow request listeners to access session + JETTY-983 Range handling cleanup diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java index fc4c63c5f17..6bf95242776 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java @@ -1340,6 +1340,7 @@ public class Request implements HttpServletRequest _requestedSessionId=null; _requestedSessionIdFromCookie=false; _session=null; + _sessionManager=null; _requestURI=null; _scope=null; _scheme=URIUtil.HTTP; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionManager.java index e93d8fdc122..7fa3d8a4c85 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionManager.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionManager.java @@ -171,39 +171,30 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement _sessionIdManager.start(); // Look for a session cookie name - String tmp=_context.getInitParameter(SessionManager.__SessionCookieProperty); - if (tmp!=null) - _sessionCookie=tmp; - - tmp=_context.getInitParameter(SessionManager.__SessionIdPathParameterNameProperty); - if (tmp!=null) + if (_context!=null) { - setSessionIdPathParameterName(tmp); - } + String tmp=_context.getInitParameter(SessionManager.__SessionCookieProperty); + if (tmp!=null) + _sessionCookie=tmp; - // set up the max session cookie age if it isn't already - if (_maxCookieAge==-1) - { - if (_context!=null) + tmp=_context.getInitParameter(SessionManager.__SessionIdPathParameterNameProperty); + if (tmp!=null) + setSessionIdPathParameterName(tmp); + + // set up the max session cookie age if it isn't already + if (_maxCookieAge==-1) { - String str=_context.getInitParameter(SessionManager.__MaxAgeProperty); - if (str!=null) - _maxCookieAge=Integer.parseInt(str.trim()); + tmp=_context.getInitParameter(SessionManager.__MaxAgeProperty); + if (tmp!=null) + _maxCookieAge=Integer.parseInt(tmp.trim()); } - } - // set up the session domain if it isn't already - if (_sessionDomain==null) - { - // only try the context initParams - if (_context!=null) - _sessionDomain=_context.getInitParameter(SessionManager.__SessionDomainProperty); - } - // set up the sessionPath if it isn't already - if (_sessionPath==null) - { - // only the context initParams - if (_context!=null) + // set up the session domain if it isn't already + if (_sessionDomain==null) + _sessionDomain=_context.getInitParameter(SessionManager.__SessionDomainProperty); + + // set up the sessionPath if it isn't already + if (_sessionPath==null) _sessionPath=_context.getInitParameter(SessionManager.__SessionPathProperty); } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java index 5134498ec35..a2a7de7d6e7 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java @@ -182,10 +182,7 @@ public class SessionHandler extends ScopedHandler } // start manual inline of nextScope(target,baseRequest,request,response); - //noinspection ConstantIfStatement - if (false) - nextScope(target,baseRequest,request,response); - else if (_nextScope!=null) + if (_nextScope!=null) _nextScope.doScope(target,baseRequest,request, response); else if (_outerScope!=null) _outerScope.doHandle(target,baseRequest,request, response); @@ -203,12 +200,16 @@ public class SessionHandler extends ScopedHandler //leaving context, free up the session if (session!=null) _sessionManager.complete(session); - baseRequest.setSessionManager(old_session_manager); - baseRequest.setSession(old_session); + + // Leave last session in place + if (old_session_manager!=null ) + { + baseRequest.setSessionManager(old_session_manager); + baseRequest.setSession(old_session); + } } } } - /* ------------------------------------------------------------ */ /* diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncContextTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncContextTest.java index 815723d254c..b2862c7ca8d 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncContextTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncContextTest.java @@ -25,6 +25,7 @@ import junit.framework.TestCase; import org.eclipse.jetty.continuation.Continuation; import org.eclipse.jetty.continuation.ContinuationListener; import org.eclipse.jetty.server.handler.HandlerWrapper; +import org.eclipse.jetty.server.session.SessionHandler; public class AsyncContextTest extends TestCase { @@ -37,7 +38,11 @@ public class AsyncContextTest extends TestCase { _connector = new LocalConnector(); _server.setConnectors(new Connector[]{ _connector }); - _server.setHandler(_handler); + + SessionHandler session = new SessionHandler(); + session.setHandler(_handler); + + _server.setHandler(session); _server.start(); } @@ -245,7 +250,8 @@ public class AsyncContextTest extends TestCase try { Thread.sleep(_resumeAfter); - asyncContext.dispatch(); + if(((HttpServletRequest)asyncContext.getRequest()).getSession(true).getId()!=null) + asyncContext.dispatch(); } catch(Exception e) {