diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java index 8be6b1899b..26684a4219 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java @@ -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> actions = this.commitActions.stream() - .map(Supplier::get).collect(Collectors.toList()); - - return Flux.concat(actions).then(); + Flux commit = Flux.empty(); + for (Supplier> actions : this.commitActions) { + commit = commit.concatWith(actions.get()); + } + return commit.then(); }