Skip to content

Commit 431ec90

Browse files
committed
Ensure buffers released in HttpHeadResponseDecorator
See gh-25908
1 parent 1d96f6a commit 431ec90

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

spring-web/src/main/java/org/springframework/http/server/reactive/HttpHeadResponseDecorator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ public final Mono<Void> writeWith(Publisher<? extends DataBuffer> body) {
5656
.then();
5757
}
5858
else {
59-
return Flux.from(body).then();
59+
return Flux.from(body)
60+
.doOnNext(DataBufferUtils::release)
61+
.then();
6062
}
6163
}
6264

spring-web/src/test/java/org/springframework/http/server/reactive/HttpHeadResponseDecoratorTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ public void writeWithGivenContentLength() {
6666

6767
@Test // gh-25908
6868
public void writeWithGivenTransferEncoding() {
69+
Flux<DataBuffer> body = Flux.just(toDataBuffer("data1"), toDataBuffer("data2"));
6970
this.response.getHeaders().add(HttpHeaders.TRANSFER_ENCODING, "chunked");
70-
this.response.writeWith(Flux.empty()).block();
71+
this.response.writeWith(body).block();
7172
assertThat(this.response.getHeaders().getContentLength()).isEqualTo(-1);
7273
}
7374

0 commit comments

Comments
 (0)