Skip to content

SseEmitter cannot format text/plain if StringHttpMessageConverter is not configured #24465

@incapable

Description

@incapable

The SseEmitter included in the spring framework does not seem to include a capable text/plain parser in the underlying converter set.

Whenever i try to send any form of event, the emitter automatically includes a "data:" prefix, which it adds with the text/plain mediatype.

After a bit of digging i noticed some of the underlying functions use a subset of spring's default MessageConverters, this subset does not include the default String converter.

So, whenever i try to send any type of event like so:

  SseEmitter.SseEventBuilder event = SseEmitter.event()
                            .data("SSE MVC - " + LocalTime.now().toString())
                            .id(String.valueOf(i))
                            .name("sse event - mvc");
                    emitter.send(event);

it will inevitably result in a
java.lang.IllegalArgumentException: No suitable converter for class java.lang.String

The suggestion would be to either include the standard string converter, or let the SseEmitter use a different mediatype for pre- and suffixes that are supported in the Converter chain for the emitter.

I'm currently on spring boot version 2.1.12.RELEASE

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions