Avoid NPE on comment SSE event

Closes gh-24389
This commit is contained in:
Rossen Stoyanchev
2020-01-20 11:26:58 +00:00
parent c20a7b4636
commit 5d8c5b0d9b
2 changed files with 17 additions and 3 deletions

View File

@@ -161,6 +161,17 @@ public class ServerSentEventHttpMessageReaderTests extends AbstractLeakCheckingT
.verify();
}
@Test // gh-24389
void readPojoWithCommentOnly() {
MockServerHttpRequest request = MockServerHttpRequest.post("/")
.body(Flux.just(stringBuffer(":ping\n"), stringBuffer("\n")));
Flux<Object> data = this.reader.read(
ResolvableType.forType(String.class), request, Collections.emptyMap());
StepVerifier.create(data).expectComplete().verify();
}
@Test // SPR-15331
public void decodeFullContentAsString() {
String body = "data:foo\ndata:bar\n\ndata:baz\n\n";