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

ServletContext.getSessionTimeout() incorrectly throws IllegalStateException #8556

Closed
lprimak opened this issue Sep 8, 2022 · 5 comments · Fixed by #10062
Closed

ServletContext.getSessionTimeout() incorrectly throws IllegalStateException #8556

lprimak opened this issue Sep 8, 2022 · 5 comments · Fixed by #10062
Assignees
Labels
Bug For general bugs on Jetty side Specification For all industry Specifications (IETF / Servlet / etc)

Comments

@lprimak
Copy link

lprimak commented Sep 8, 2022

Jetty version(s)
10.0.11 and newer

Java version/vendor (use: java -version)
Doesn't matter

OS type/version
Doesn't matter

Description
Jetty throws IllegalStateException when ServletContext.getSessionTimeout() is called from a servlet filter, or a plain servlet.
This violates the servlet spec.
See Javadoc: https://javadoc.io/static/javax.servlet/javax.servlet-api/4.0.1/javax/servlet/ServletContext.html#getSessionTimeout--
or the servlet spec.

No exception should be thrown and a valid session timeout (in minutes) should be returned instead.

How to reproduce?
request.getServletContext().getSessionTimeout() in a servlet filter

@lprimak lprimak added the Bug For general bugs on Jetty side label Sep 8, 2022
@joakime joakime added the Specification For all industry Specifications (IETF / Servlet / etc) label Sep 8, 2022
@joakime
Copy link
Contributor

joakime commented Sep 8, 2022

This is a curious one, as we pass the Servlet 4.0 TCK. Wonder if this isn't even tested for in the TCK?

@lprimak
Copy link
Author

lprimak commented Sep 8, 2022

Probably not tested by the TCK…
This also needs to work regardless if there is a session present

@lprimak
Copy link
Author

lprimak commented Jul 5, 2023

bump please :)

@janbartel
Copy link
Contributor

@lprimak thanks for the nudge - don't know how this one escaped my attention. You're right, according to the javadoc you should be able to call SessionContext.getSessionTimeout() outside of the startup sequence (modulo the provision for UnsupportedOperationException). The TCK either doesn't test this, or possibly only tests it from inside a ServletContainerInitializer as we were doing.

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 Specification For all industry Specifications (IETF / Servlet / etc)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants