Skip to content

Decoding ServerSentEvent fails when using generic type [SPR-16744] #21285

@spring-projects-issues

Description

@spring-projects-issues

Anton Brok-Volchansky opened SPR-16744 and commented

First element is decoded correct, but stream fails on the second element:

@Test
public void sseAsEventOfObject() {
	ParameterizedTypeReference<ServerSentEvent<Person>> type = new ParameterizedTypeReference<ServerSentEvent<Person>>() {};

	Flux<ServerSentEvent<Person>> result = this.webClient.get()
			.uri("/sseeventperson")
			.accept(TEXT_EVENT_STREAM)
			.retrieve()
			.bodyToFlux(type);

	StepVerifier.create(result)
			.consumeNextWith( event -> {
				assertEquals("1", event.id());
				assertEquals(new Person("Jonathan", "Smith"), event.data());
			})
			.consumeNextWith( event -> {
				assertEquals("2", event.id());
				assertEquals(new Person("Jonathan", "Doe"), event.data());
			})
			.expectComplete()
			.verify(Duration.ofSeconds(5555L));
}

(Other code is ommited)
When using String as generic parameter, there is no problem at all (as well as in your tests there are no problem when they run). But when I debug the SSE reader and SSE writer in case of use Person, I see two new line between elements instead of one.


Affects: 5.0.4, 5.0.5

Issue Links:

Referenced from: commits da98ff7, 66bd277

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions