See gh-22341
This commit is contained in:
Brian Clozel 2019-02-11 10:46:27 +01:00
parent fb4a28f904
commit afbe7b31bb
1 changed files with 6 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
import org.reactivestreams.Publisher;
@ -215,7 +214,6 @@ public abstract class AbstractServerHttpResponse implements ServerHttpResponse {
if (!this.state.compareAndSet(State.NEW, State.COMMITTING)) {
return Mono.empty();
}
this.commitActions.add(() ->
Mono.fromRunnable(() -> {
applyStatusCode();
@ -223,15 +221,14 @@ public abstract class AbstractServerHttpResponse implements ServerHttpResponse {
applyCookies();
this.state.set(State.COMMITTED);
}));
if (writeAction != null) {
this.commitActions.add(writeAction);
}
List<? extends Mono<Void>> actions = this.commitActions.stream()
.map(Supplier::get).collect(Collectors.toList());
return Flux.concat(actions).then();
Flux<Void> commit = Flux.empty();
for (Supplier<? extends Mono<Void>> actions : this.commitActions) {
commit = commit.concatWith(actions.get());
}
return commit.then();
}