Skip to content

Commit

Permalink
Issue #9181 NPE in SessionHandler (#9346)
Browse files Browse the repository at this point in the history
Cherry pick back to 9.4
  • Loading branch information
janbartel committed Feb 15, 2023
1 parent 1be1401 commit 722781d
Showing 1 changed file with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1727,33 +1727,36 @@ else if (!DispatcherType.REQUEST.equals(baseRequest.getDispatcherType()))
if (isUsingURLs() && (requestedSessionId == null))
{
String uri = request.getRequestURI();
String prefix = getSessionIdPathParameterNamePrefix();
if (prefix != null)
if (uri != null)
{
int s = uri.indexOf(prefix);
if (s >= 0)
String prefix = getSessionIdPathParameterNamePrefix();
if (prefix != null)
{
s += prefix.length();
int i = s;
while (i < uri.length())
int s = uri.indexOf(prefix);
if (s >= 0)
{
char c = uri.charAt(i);
if (c == ';' || c == '#' || c == '?' || c == '/')
break;
i++;
}
s += prefix.length();
int i = s;
while (i < uri.length())
{
char c = uri.charAt(i);
if (c == ';' || c == '#' || c == '?' || c == '/')
break;
i++;
}

requestedSessionId = uri.substring(s, i);
requestedSessionIdFromCookie = false;
requestedSessionId = uri.substring(s, i);
requestedSessionIdFromCookie = false;

if (LOG.isDebugEnabled())
LOG.debug("Got Session ID {} from URL", requestedSessionId);
if (LOG.isDebugEnabled())
LOG.debug("Got Session ID {} from URL", requestedSessionId);

session = getHttpSession(requestedSessionId);
if (session != null && isValid(session))
{
baseRequest.enterSession(session); //request enters this session for first time
baseRequest.setSession(session); //associate the session with the request
session = getHttpSession(requestedSessionId);
if (session != null && isValid(session))
{
baseRequest.enterSession(session); //request enters this session for first time
baseRequest.setSession(session); //associate the session with the request
}
}
}
}
Expand Down

0 comments on commit 722781d

Please sign in to comment.