spring-framework
spring-framework copied to clipboard
Reduce synchronization in ResponseBodyEmitter
ResponseBodyEmitter relies on synchronization to protect against concurrent use of the response, and also for the caching of early messages (e.g. before the emitter is returned from the controller method) to be properly detected from another thread that sends after initialization.
After #32340, protection against concurrent use of the response is built deeper at the level of StandardServletAsyncWebRequest, so we can revisit ResponseBodyEmitter and leave only synchronization that is actually necessary.
See also https://github.com/spring-projects/spring-framework/issues/34762#issuecomment-2809047490 for related efforts in 6.2.x to optimize performance.