Skip to content

Fix handling of ServerSentEvent with Jackson encoder #35872

@heowc

Description

@heowc

I'm using spring-webflux and was returning responses like this:

@GetMapping("test")
public Flux<ServerSentEvent<String>> test() {
    return Flux.interval(Duration.ofSeconds(1))
        .take(Duration.ofSeconds(3))
        .map(i -> ServerSentEvent.builder("Hello " + i).build());
}

The content-type changed when upgrading to 7.0.1.

AS-IS: Content-Type: text/event-stream;charset=UTF-8
TO-BE: Content-Type: application/json

So, I need to change it to the following to get the same behavior as before. Is this intended?

@GetMapping(value = "test", produces = "text/event-stream")
public Flux<ServerSentEvent<String>> test() { 
    return Flux.interval(Duration.ofSeconds(1)) 
        .take(Duration.ofSeconds(3)) 
        .map(i -> ServerSentEvent.builder("Hello " + i).build());
}

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions