SseEmitter should ignore calls to send after timeout [SPR-13498] #18076
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
Konrad Garus opened SPR-13498 and commented
Let's say I have a misbehaving handler that keeps using SseEmitter even though it's closed/timed out:
When I get the event stream for the first time, it looks like you would expect, except for the JSON at the very bottom (see #18075):
Now, have a look at what happens on reconnect:
We can see both threads writing to the same connection, even though the first emitter was supposedly closed!
What's even more interesting, it's not limited to that endpoint or SSE streams. Here's what happens when I try to load a static resource:
Note the "data:data:data:..." on top.
Yes, the code leading to this bug is broken. It's just a made-up example though. I suspect in the real life such issues are still possible with clean-looking code.
I think this should be addressed by preventing use of a closed
SseEmitter
. If you try to send an event to one, you get an exception immediately and it doesn't even try to touch the underlying connection. Logically something like:Affects: 4.2.1
Issue Links:
The text was updated successfully, but these errors were encountered: