From 06d4bb6a1a42a50cba2f0e39f8ef405fd46f53cd Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Thu, 1 Sep 2016 16:08:35 +0200 Subject: [PATCH] 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 --- .../http/codec/ServerSentEventHttpMessageWriter.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java index 2568ad11f27..ceeabd75e7b 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java @@ -79,10 +79,6 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter> 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); }