Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Sep 30, 2020

Conversation

janbartel
Copy link
Contributor

Closes #5365

SessionHandler.newHttpSession(Request) is called by Request.getSession(true) when a new session needs to be created. If SessionHandler fails to create the session for whatever reason, it logs the exception and returns null. Request.getSession(true) isn't expecting a null and can cause a confusing NPE elsewhere deeper in the code. As Request.getSession(boolean) is a servlet api method, it cannot throw a checked exception, nor according to the api can it return null. So we throw ISE if SessionHandler.newHttpSession(Request) returns null. I think in jetty-10 it would be better to modify the signature of SessionHandler.newHttpSession(Request) to throw the exception rather than catching and returning null.

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>
@janbartel janbartel self-assigned this Sep 30, 2020
@joakime
Copy link
Contributor

joakime commented Sep 30, 2020

To other devs, this is flagged for 9.4.33, do not merge into jetty-9.4.x (yet)

@gregw gregw merged commit eb02009 into jetty-9.4.x Sep 30, 2020
@gregw gregw deleted the jetty-9.4.x-5365-NPE-newHttpSession branch September 30, 2020 14:51
@olamy olamy added the Bug For general bugs on Jetty side label Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants