Issue #9181 NPE in SessionHandler (#9346)

This commit is contained in:
Jan Bartel 2023-02-14 13:22:59 +11:00 committed by GitHub
parent 622befbd0d
commit e75ec5e37a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 21 deletions

View File

@ -1673,33 +1673,36 @@ public class SessionHandler extends ScopedHandler
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
}
}
}
}