jakartaee / jakartaee/servlet

Some ServletContext getters still throw UnsupportedOperationException

Open
#470 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
325
Forks
112
PR merge metrics
No merged PRs in 30d

Description

The following Servlet 6.0 issue removed this restriction from a number of getter methods: https://github.com/jakartaee/servlet/issues/416.

However, the following getter methods still throw an UnsupportedOperationException:

1. https://jakarta.ee/specifications/servlet/6.0/apidocs/jakarta.servlet/jakarta/servlet/servletcontext#getServletRegistration(java.lang.String)
2. https://jakarta.ee/specifications/servlet/6.0/apidocs/jakarta.servlet/jakarta/servlet/servletcontext#getServletRegistrations()
3. https://jakarta.ee/specifications/servlet/6.0/apidocs/jakarta.servlet/jakarta/servlet/servletcontext#getFilterRegistration(java.lang.String)
4. https://jakarta.ee/specifications/servlet/6.0/apidocs/jakarta.servlet/jakarta/servlet/servletcontext#getFilterRegistrations()
5. https://jakarta.ee/specifications/servlet/6.0/apidocs/jakarta.servlet/jakarta/servlet/servletcontext#getSessionCookieConfig()

In addition, the Specification document still declares the following: https://github.com/jakartaee/servlet/blob/master/spec/src/main/asciidoc/servlet-spec-body.adoc#44-configuration-methods

> The following methods are provided on the ServletContext interface to enable programmatic definition of servlets, filters and the url pattern(s) that they map to. These methods can only be called during the initialization of the application either from the contexInitialized method of a ServletContextListener implementation or from the onStartup method of a ServletContainerInitializer implementation. In addition to adding servlets and filters, one can also look up an instance of a Registration object corresponding to a servlet or filter or a map of all the Registration objects for the servlets or filters. If a ServletContext is passed to the ServletContextListener’s contextInitialized method where the ServletContextListener was neither declared in web.xml or web-fragment.xml nor annotated with @WebListener then an UnsupportedOperationException MUST be thrown for all the methods defined in ServletContext for programmatic configuration of servlets, filters and listeners.

**I'd like to start a discussion about cleaning up these remaining "getters" and potentially a specification document update to ensure it matches the API.**

Contributor guide

Open the contributing guide

Research direction

Start by reading the ServletContext getter links and the configuration-methods section in spec/src/main/asciidoc/servlet-spec-body.adoc, alongside the referenced Servlet 6.0 issue. Determine the intended behavior for the five getters and whether the specification text should change; done means the API behavior and specification are consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend, documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.