Repository navigation
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: regressionA bug that is also a regressionA bug that is also a regression
Milestone
Description
I'm working on migrating my project from spring boot 3.5.11 to 4.0.3 and I've come across an issue with interceptors and websockets. My application works properly on version 3.5.11, but fails when stepping up to 4.0.3. I've created a minimal example project to demonstrate the issue which I'll link here.
https://github.com/tstocker-black-cape/spring-graphql-websocket-bug-example
It's possible that something has changed between versions and I'm now doing something wrong, but I'm able to recreate the issue in the example.
When attempting to call a subscription endpoint backed by a websocket, the call closes with code 1011 and the server responds with
{
"errors": [
{
"message": "Unknown GraphQL error"
}
]
}
In the server, an exception is thrown
java.lang.IllegalStateException: The request object has been recycled and is no longer associated with this facade
at org.apache.catalina.connector.RequestFacade.checkFacade(RequestFacade.java:609)
at org.apache.catalina.connector.RequestFacade.getHeader(RequestFacade.java:287)
at jakarta.servlet.http.HttpServletRequestWrapper.getHeader(HttpServletRequestWrapper.java:82)
at org.springframework.security.web.firewall.StrictHttpFirewall$StrictFirewalledRequest.getHeader(StrictHttpFirewall.java:724)
at jakarta.servlet.http.HttpServletRequestWrapper.getHeader(HttpServletRequestWrapper.java:82)
at jakarta.servlet.http.HttpServletRequestWrapper.getHeader(HttpServletRequestWrapper.java:82)
at org.springframework.http.server.ServletRequestHeadersAdapter.getFirst(ServletRequestHeadersAdapter.java:59)
at org.springframework.http.server.ServletRequestHeadersAdapter.getFirst(ServletRequestHeadersAdapter.java:47)
at org.springframework.http.server.ServletRequestHeadersAdapter$RequestHeaderOverrideWrapper.getFirst(ServletRequestHeadersAdapter.java:266)
at org.springframework.http.server.ServletRequestHeadersAdapter$RequestHeaderOverrideWrapper.getFirst(ServletRequestHeadersAdapter.java:253)
at org.springframework.http.HttpHeaders.getFirst(HttpHeaders.java:1784)
...
Reacted by Ian McBee, Trey-Young227 and Jamesferro76
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: regressionA bug that is also a regressionA bug that is also a regression
Activity
[-][BUG] WebGraphQlInterceptor fails when executing a subscription in spring boot 4.0.3[/-][+]WebGraphQlInterceptor fails when executing a subscription in spring boot 4.0.3[/+][-]WebGraphQlInterceptor fails when executing a subscription in spring boot 4.0.3[/-][+]IllegalStateException when using websocket handshake headers with Tomcat[/+]bclozel commentedon Mar 17, 2026
Thanks for the report and sample @tstocker-black-cape , this is really useful. This is a regression introduced in Framework.
As of #36334, Spring Framework is managing HTTP request headers natively, without overhead. This means that referring to headers once the HTTP exchange has been completed is not possible anymore: data has been recycled by the Servlet engine, and this is what the
IllegalStateExceptionshows.The HTTP headers from the WebSocket handshake cannot be reused once the hanshake has been completed, so we must copy their values in the websocket session and not use the original reference.
I'll transfer the issue and fix it in Framework directly.
Copy WS handshake headers to store in session
tstocker-black-cape commentedon Mar 17, 2026
Thank you!