Skip to content

Commit

Permalink
Defer cleanup in DefaultServerWebExchange
Browse files Browse the repository at this point in the history
This commit ensures that the multipartRead flag is read in a deferred
block, and is not evaluated too early.

Closes gh-31567
  • Loading branch information
poutsma committed Nov 7, 2023
1 parent 7f94c64 commit dc26d3b
Showing 1 changed file with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,20 @@ public Mono<MultiValueMap<String, Part>> getMultipartData() {

@Override
public Mono<Void> cleanupMultipart() {
if (this.multipartRead) {
return getMultipartData()
.onErrorResume(t -> Mono.empty()) // ignore errors reading multipart data
.flatMapIterable(Map::values)
.flatMapIterable(Function.identity())
.flatMap(part -> part.delete()
.onErrorResume(ex -> Mono.empty()))
.then();
}
else {
return Mono.empty();
}
return Mono.defer(() -> {
if (this.multipartRead) {
return getMultipartData()
.onErrorComplete()
.flatMapIterable(Map::values)
.flatMapIterable(Function.identity())
.flatMap(part -> part.delete()
.onErrorComplete())
.then();
}
else {
return Mono.empty();
}
});
}

@Override
Expand Down

0 comments on commit dc26d3b

Please sign in to comment.