Skip to content

Commit

Permalink
Issue #5365 ISE not NPE if fail to create session.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
janbartel committed Sep 30, 2020
1 parent 3423375 commit f8c2100
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,9 @@ public HttpSession getSession(boolean create)
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);
Expand Down

0 comments on commit f8c2100

Please sign in to comment.