Skip to content

Commit

Permalink
Refine Reactor Netty handling of request without body
Browse files Browse the repository at this point in the history
Closes gh-34003
  • Loading branch information
rstoyanchev committed Dec 2, 2024
1 parent 320831b commit 15dcc44
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ private Publisher<Void> send(
headers.forEach((key, value) -> request.requestHeaders().set(key, value));

if (body == null) {
return outbound;
// NettyOutbound#subscribe calls then() and that expects a body
// Use empty Mono instead for a more optimal send
return Mono.empty();
}

AtomicReference<Executor> executorRef = new AtomicReference<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ public Mono<Void> writeWith(Path file, long position, long count) {

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ public Mono<Void> writeWith(Path file, long position, long count) {

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

@Override
Expand Down

0 comments on commit 15dcc44

Please sign in to comment.