Closed spring-projects-issues closed 8 years ago
Rossen Stoyanchev commented
I've removed the class cast and added a build method to SseEventBuilder.
By the way I'd interested to hear more about your use case with creating a custom message, i.e. the underlying reason for wanting to extend SseEventBuilder.
Maksym Shalak commented
We just wanted to get rid of the "data:" prefix and pass pure JSON into the stream.
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?
Maksym Shalak commented
Yep, looks like ResponseBodyEmitter better suites my needs, thanks.
Maksym Shalak opened SPR-13591 and commented
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. So basically that means we cannot create our custom messages at all.
Affects: 4.2.1
Attachments:
Referenced from: commits https://github.com/spring-projects/spring-framework/commit/1c382be00e39060a0a4005d80098365f2bee45d4