Skip to content

Commit 15dcc44

Browse files
committed
Refine Reactor Netty handling of request without body
Closes gh-34003
1 parent 320831b commit 15dcc44

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

spring-web/src/main/java/org/springframework/http/client/ReactorClientHttpRequest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ private Publisher<Void> send(
145145
headers.forEach((key, value) -> request.requestHeaders().set(key, value));
146146

147147
if (body == null) {
148-
return outbound;
148+
// NettyOutbound#subscribe calls then() and that expects a body
149+
// Use empty Mono instead for a more optimal send
150+
return Mono.empty();
149151
}
150152

151153
AtomicReference<Executor> executorRef = new AtomicReference<>();

spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpRequest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ public Mono<Void> writeWith(Path file, long position, long count) {
120120

121121
@Override
122122
public Mono<Void> setComplete() {
123-
return doCommit(this.outbound::then);
123+
// NettyOutbound#then() expects a body
124+
// Use null as the write action for a more optimal send
125+
return doCommit(null);
124126
}
125127

126128
@Override

spring-web/src/main/java/org/springframework/http/client/reactive/ReactorNetty2ClientHttpRequest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ public Mono<Void> writeWith(Path file, long position, long count) {
123123

124124
@Override
125125
public Mono<Void> setComplete() {
126-
return doCommit(this.outbound::then);
126+
// NettyOutbound#then() expects a body
127+
// Use null as the write action for a more optimal send
128+
return doCommit(null);
127129
}
128130

129131
@Override

0 commit comments

Comments
 (0)