https://github.com/spring-projects/spring-framework/issues/30996 fixed thread pinning issue. But only for SSEEmitter. Still there are several synchronized block in ResponseBodyEmitter.
https://github.com/spring-projects/spring-framework/blob/e5b58effa3b74569ca6d3b091fa44f47bdc6ccea/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitter.java#L183
https://github.com/spring-projects/spring-framework/blob/e5b58effa3b74569ca6d3b091fa44f47bdc6ccea/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitter.java#L211
To prevent thread pinning when using virtual thread, it have to replaced with ReentrantLock
.
Many of us cannot move to JDK 24 yet (which reduces synchronized pinning), so we need a framework-level mitigation.
Comment From: bclozel
Superseded by #35423