Let users control SSE stream completion

This commit avoid merging automatically the SSE stream with
Flux.never(). Since browsers automatically reconnect when
the HTTP connection is closed, it is now the user responsability
to optionally perform a concatWith(Flux.never()) on streams that
complete in order to avoid receiving the data multiple times on
client side.

The behavior with hot streams that never complete does not change.

Issue: SPR-14578
This commit is contained in:
Sebastien Deleuze
2016-09-01 16:08:35 +02:00
parent 1af2fbfbbb
commit 06d4bb6a1a

View File

@@ -79,10 +79,6 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter<Objec
DataBufferFactory bufferFactory = outputMessage.bufferFactory();
Flux<Publisher<DataBuffer>> body = encode(inputStream, bufferFactory, type);
// Keep the SSE connection open even for cold stream in order to avoid
// unexpected browser reconnection
body = body.concatWith(Flux.never());
return outputMessage.writeAndFlushWith(body);
}