See gh-22341
This commit is contained in:
Brian Clozel
2019-02-11 10:46:27 +01:00
parent fb4a28f904
commit afbe7b31bb

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