-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: bugA general bugA general bug
Milestone
Description
Tomasz Nurkiewicz opened SPR-13224 and commented
SseEmitter
misbehaves when multiple threads call send()
at the same time. Sometimes container fails, but most of the time different messages get interleaved, e.g.:
emitter.send("foo"); //thread A
emitter.send("bar"); //thread B
sometimes results in:
data:data:AB
It happens because emitter.send("A")
actually sends three independent messages: data:
, A
and \n\n
. These three messages can be interleaved with messages from different threads. Please either synchronize properly or document clearly that SseEmitter
is not thread safe, so that if clients want to use from multiple threads (I think it's quite useful), it must be synchronized manually:
synchronized(sseEmitter) {
sseEmitter.send("foo");
}
Affects: 4.2 RC2
Issue Links:
- ResponseBodyEmitter skips same messages during initialization [SPR-13223] #17814 ResponseBodyEmitter skips same messages during initialization
Referenced from: commits bdb6348
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: bugA general bugA general bug