Fix memory leak for ServerSentEventHttpMessageWriter
Issue: SPR-17419
This commit is contained in:
@@ -32,6 +32,8 @@ import org.springframework.core.codec.Encoder;
|
|||||||
import org.springframework.core.codec.Hints;
|
import org.springframework.core.codec.Hints;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||||
|
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||||
|
import org.springframework.core.io.buffer.PooledDataBuffer;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ReactiveHttpOutputMessage;
|
import org.springframework.http.ReactiveHttpOutputMessage;
|
||||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||||
@@ -144,7 +146,8 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter<Objec
|
|||||||
|
|
||||||
return Flux.concat(encodeText(sb, mediaType, factory),
|
return Flux.concat(encodeText(sb, mediaType, factory),
|
||||||
encodeData(data, valueType, mediaType, factory, hints),
|
encodeData(data, valueType, mediaType, factory, hints),
|
||||||
encodeText("\n", mediaType, factory));
|
encodeText("\n", mediaType, factory))
|
||||||
|
.doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user