Skip to content

Commit

Permalink
Issue #4156 Session already in cache
Browse files Browse the repository at this point in the history
+ check validity of sessions in getSession(SessionHandler)
+ do not replace session in doScope if SessionHandler is the same.

Signed-off-by: Greg Wilkins <gregw@webtide.com>
  • Loading branch information
gregw committed Oct 4, 2019
1 parent 50d7b8c commit 8b08b0f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,8 @@ public HttpSession getSession(SessionHandler sessionHandler)
if (sessionHandler == ss.getSessionHandler())
{
session = s;
break;
if (ss.isValid())
return session;
}
}
return session;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;

import javax.servlet.DispatcherType;
import javax.servlet.ServletException;
import javax.servlet.SessionCookieConfig;
Expand Down Expand Up @@ -1523,19 +1522,22 @@ public void doScope(String target, Request baseRequest, HttpServletRequest reque
oldSessionHandler = baseRequest.getSessionHandler();
oldSession = baseRequest.getSession(false);

//find any existing session for this request that has already been accessed
existingSession = baseRequest.getSession(this);
if (existingSession == null)
if (oldSessionHandler != this)
{
//session for this context has not been visited previously,
//try getting it
baseRequest.setSession(null);
checkRequestedSessionId(baseRequest, request);
existingSession = baseRequest.getSession(false);
}
//find any existing session for this request that has already been accessed
existingSession = baseRequest.getSession(this);
if (existingSession == null)
{
//session for this context has not been visited previously,
//try getting it
baseRequest.setSession(null);
checkRequestedSessionId(baseRequest, request);
existingSession = baseRequest.getSession(false);
}

baseRequest.setSession(existingSession);
baseRequest.setSessionHandler(this);
baseRequest.setSession(existingSession);
baseRequest.setSessionHandler(this);
}
break;
}
default:
Expand Down

0 comments on commit 8b08b0f

Please sign in to comment.