Skip to content

Commit afbe7b3

Browse files
committed
Polish
See gh-22341
1 parent fb4a28f commit afbe7b3

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
2020
import java.util.List;
2121
import java.util.concurrent.atomic.AtomicReference;
2222
import java.util.function.Supplier;
23-
import java.util.stream.Collectors;
2423

2524
import org.apache.commons.logging.Log;
2625
import org.reactivestreams.Publisher;
@@ -215,23 +214,21 @@ protected Mono<Void> doCommit(@Nullable Supplier<? extends Mono<Void>> writeActi
215214
if (!this.state.compareAndSet(State.NEW, State.COMMITTING)) {
216215
return Mono.empty();
217216
}
218-
219217
this.commitActions.add(() ->
220218
Mono.fromRunnable(() -> {
221219
applyStatusCode();
222220
applyHeaders();
223221
applyCookies();
224222
this.state.set(State.COMMITTED);
225223
}));
226-
227224
if (writeAction != null) {
228225
this.commitActions.add(writeAction);
229226
}
230-
231-
List<? extends Mono<Void>> actions = this.commitActions.stream()
232-
.map(Supplier::get).collect(Collectors.toList());
233-
234-
return Flux.concat(actions).then();
227+
Flux<Void> commit = Flux.empty();
228+
for (Supplier<? extends Mono<Void>> actions : this.commitActions) {
229+
commit = commit.concatWith(actions.get());
230+
}
231+
return commit.then();
235232
}
236233

237234

0 commit comments

Comments
 (0)