-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Revisit Servlet API baseline: Servlet 6.0 in the build, Servlet 5.0 compatibility at runtime #29435
Comments
This is a breaking change for us. We use the Spring Mocks in our tests too, and therefore had to update to compile vs. Servlet 6. However, we have classes which implement and proxy ServletConnection getServletConnection();
Please reconsider. |
Unfortunately, we have no choice here. Compiling against Servlet 5, some parts of our framework arrangement and in particular the mocks would be incompatible with Servlet 6 (due to having to refer to the now-removed On a forward-looking note, it is more important to be compatible with Servlet 6+ than to make Servlet 5 usage convenient. In all likelihood, Servlet 5 will be very short-lived in the Spring ecosystem, only really relevant for Jetty 11 purposes until Jetty 12 goes GA some time next year. If it wasn't for Jetty, we might have been able to launch with a Servlet 6 baseline right away. Note that the framework itself is compatible with Servlet 5 containers at production level. It is literally just the mocks that bring in Servlet 6, and the mocks are not meant to be used in a Servlet container environment to begin with. For compilation purposes with a Servlet 5 compatibility impact, we recommend compiling your main sources against the Servlet 5.0 API jar and your mock-using test sources against the Servlet 6.0 API jar, side by side. Last but not least, for custom purposes where our mocks leak through to production sources in some form, feel free to fork them for the time being, maybe even just fork As a side thought, if you prefer building your main sources against Servlet 6 as well, you could possibly derive from P.S.: I clarified the issue description that our mocks mean to retain compatibility with Servlet 5 based code that is being tested, not with running against the Servlet 5.0 API themselves. The mocks are based on the Servlet 6.0 API now, requiring the latter on the test classpath. FWIW we had a similar situation before with Servlet 4.0 vs 3.1 where the mocks were 4.0 based as well. |
Thanks for the guidance. We're going to try to fork the relevant mock as suggested and see if that gets us back to the status quo for now. If that doesn't work out, we may have to wait for Jetty 12 (Jetty's our preferred container, for various reasons) and skip Servlet 5. Again, knowing that you think Servlet 5 is not going to have a position longer term is useful information. There's something to be said for getting all the transitions out of the way at once rather than one by one. |
jetty 11 only runs against servlet api 5, but spring boot 3 will be launched with servlet api 6. solution for now seems to be an explicit downgrade of our servlet api dependency and wait for jetty 12 to release. background: spring-projects/spring-framework#29435
@jhoeller will Servlet 6(once Jetty 12 goes GA) become baseline for Spring Framework 6.1? Also dropping support for Servlet 5 containers in 6.1 timeframe. |
At this point, we have no intentions to drop Servlet 5 runtime compatibility at the core framework level since it is easy enough to retain still. We just intend to drop Jetty 11 support in WebFlux as of Spring Framework 6.1 due to incompatibities in the Jetty 12 APIs, just retaining Jetty 11 compatibility for Spring MVC as part of our general Servlet 5 runtime compatibility. At Spring Boot level, it looks like there will be a consistent Servlet 6 baseline from version 3.2 onwards, including Jetty 12 in all stack variants. |
While Spring Framework 6.0 intends to retain a Servlet 5.0 (Jakarta EE 9) baseline for the time being, there is a breaking change in Servlet 6.0 (Jakarta EE 10) that we need to take into account: the removal of the deprecated
HttpSessionContext
interface which makes existing implementations ofHttpSession
non-resolvable against the Servlet 6.0 API, as long as they keep implementing the deprecatedgetSessionContext()
method.This affects our Servlet API mocks which effectively do not work in a Servlet 6.0 setup. By compiling against Servlet 6.0, we can avoid implementing the deprecated
getSessionContext()
method while still retaining compatibility with Servlet 5.0 based code - except forgetSessionContext()
which threw anUnsupportedOperationException
before in any case.This also enables us to use new Servlet 6.0 facilities where appropriate - any time in the Spring Framework 6.x generation. Aside from avoiding 5.0-deprecated methods for Servlet 6.0 compatibility (where they got removed), no specific support for Servlet 6.0 mechanisms (such as
ServletRequest.getServletConnection()
orCookie
attributes) has been introduced yet.The text was updated successfully, but these errors were encountered: