Skip to content

Commit 722781d

Browse files
committed
Issue #9181 NPE in SessionHandler (#9346)
Cherry pick back to 9.4
1 parent 1be1401 commit 722781d

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,33 +1727,36 @@ else if (!DispatcherType.REQUEST.equals(baseRequest.getDispatcherType()))
17271727
if (isUsingURLs() && (requestedSessionId == null))
17281728
{
17291729
String uri = request.getRequestURI();
1730-
String prefix = getSessionIdPathParameterNamePrefix();
1731-
if (prefix != null)
1730+
if (uri != null)
17321731
{
1733-
int s = uri.indexOf(prefix);
1734-
if (s >= 0)
1732+
String prefix = getSessionIdPathParameterNamePrefix();
1733+
if (prefix != null)
17351734
{
1736-
s += prefix.length();
1737-
int i = s;
1738-
while (i < uri.length())
1735+
int s = uri.indexOf(prefix);
1736+
if (s >= 0)
17391737
{
1740-
char c = uri.charAt(i);
1741-
if (c == ';' || c == '#' || c == '?' || c == '/')
1742-
break;
1743-
i++;
1744-
}
1738+
s += prefix.length();
1739+
int i = s;
1740+
while (i < uri.length())
1741+
{
1742+
char c = uri.charAt(i);
1743+
if (c == ';' || c == '#' || c == '?' || c == '/')
1744+
break;
1745+
i++;
1746+
}
17451747

1746-
requestedSessionId = uri.substring(s, i);
1747-
requestedSessionIdFromCookie = false;
1748+
requestedSessionId = uri.substring(s, i);
1749+
requestedSessionIdFromCookie = false;
17481750

1749-
if (LOG.isDebugEnabled())
1750-
LOG.debug("Got Session ID {} from URL", requestedSessionId);
1751+
if (LOG.isDebugEnabled())
1752+
LOG.debug("Got Session ID {} from URL", requestedSessionId);
17511753

1752-
session = getHttpSession(requestedSessionId);
1753-
if (session != null && isValid(session))
1754-
{
1755-
baseRequest.enterSession(session); //request enters this session for first time
1756-
baseRequest.setSession(session); //associate the session with the request
1754+
session = getHttpSession(requestedSessionId);
1755+
if (session != null && isValid(session))
1756+
{
1757+
baseRequest.enterSession(session); //request enters this session for first time
1758+
baseRequest.setSession(session); //associate the session with the request
1759+
}
17571760
}
17581761
}
17591762
}

0 commit comments

Comments
 (0)