Closed spring-projects-issues closed 6 years ago
Rossen Stoyanchev commented
We could expose the flag but I'm not sure it would really help. The send()
can fail with the given sample code because another thread set "complete" after the while check and before the call to send. The flag can also be set through container events too, by the way, such as a timeout or error.
So you need to always expect a possible exception from send and at that point it becomes your check, i.e. you keep sending until you cannot any more:
while (true) {
try {
emitter.send();
}
catch (Exception ex) {
// Done
}
}
Yanming Zhou commented
Yes, your suggestion is a better solution.
Yanming Zhou opened SPR-16476 and commented
Affects: 5.0.3