Issue #5365 ISE not NPE if fail to create session. (#5370)

If SessionHandler.newHttpSession(Request) fails to create a session
it returns null. Request.getSession(true) cannot throw a checked
exception, nor can it return null, so we should throw ISE.

Signed-off-by: Jan Bartel <janb@webtide.com>
This commit is contained in:
Jan Bartel 2020-09-30 16:51:54 +02:00 committed by GitHub
parent c7e52eeecb
commit eb02009f87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -1623,6 +1623,9 @@ public class Request implements HttpServletRequest
throw new IllegalStateException("No SessionManager");
_session = _sessionHandler.newHttpSession(this);
if (_session == null)
throw new IllegalStateException("Create session failed");
HttpCookie cookie = _sessionHandler.getSessionCookie(_session, getContextPath(), isSecure());
if (cookie != null)
_channel.getResponse().replaceCookie(cookie);