parent
c20a7b4636
commit
5d8c5b0d9b
|
|
@ -135,7 +135,10 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader<Objec
|
|||
return this.lineDecoder.decode(message.getBody(), STRING_TYPE, null, hints)
|
||||
.doOnNext(limitTracker::afterLineParsed)
|
||||
.bufferUntil(String::isEmpty)
|
||||
.map(lines -> buildEvent(lines, valueType, shouldWrap, hints));
|
||||
.concatMap(lines -> {
|
||||
Object event = buildEvent(lines, valueType, shouldWrap, hints);
|
||||
return (event != null ? Mono.just(event) : Mono.empty());
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
@ -168,7 +171,7 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader<Objec
|
|||
}
|
||||
}
|
||||
|
||||
Object decodedData = data != null ? decodeData(data.toString(), valueType, hints) : null;
|
||||
Object decodedData = (data != null ? decodeData(data.toString(), valueType, hints) : null);
|
||||
|
||||
if (shouldWrap) {
|
||||
if (comment != null) {
|
||||
|
|
@ -180,7 +183,7 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader<Objec
|
|||
return sseBuilder.build();
|
||||
}
|
||||
else {
|
||||
return decodedData;
|
||||
return (decodedData);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
Loading…
Reference in New Issue