SseEmitter cannot use "send(SseEventBuilder builder)" method with custom SseEventBuilder implementation [SPR-13591] #18169
SseEmitter class contains method "send(SseEventBuilder builder)" which is supposed to be used for custom messages. But the first line of this method contains code
That means if we pass SseEventBuilder to the method we receive a ClassCastException since we cannot cast our implementation of interface SseEventBuilder to built-in implementation SseEventBuilderImpl. And SseEventBuilderImpl is a private class, so we will not be able to override it.
Referenced from: commits 1c382be
Rossen Stoyanchev commented
Is this for Server-Sent Events you mean? According to the spec the field name should be: event, data, id, retry, or otherwise should be ignored. Or if you just want to stream data to the response (not necessarily SSE-formatted) why not use ResponseBodyEmitter instead of SseEmitter?