requireExplicitBindings do not work for Servlet Module
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 1.7k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
> Note: Every servlet (or filter) is required to be a @Singleton. If you cannot annotate the class directly, you must bind it using bind(..).in(Singleton.class), separate to the filter() or servlet() rules. Mapping under any other scope is an error. This is to maintain consistency with the Servlet specification. Guice Servlet does not support the deprecated SingleThreadModel.
We use binder().requireExplicitBindings() in order to avoid missing any bindings. This ensures we explicitly add their scope.
However, when the module is a ServletModule, this restriction doesn't seem to work.
One possible reason I could think of is that internally in Guice Servlet, ServletDefinition is the main entity and HttpServlet is mostly used as a proxy, so no injections are actually taking place for it to be explicitly bound.
Contributor guide
Assessment
This issue has not been assessed yet.