/** * Apply {@link #beforeCommit(Supplier) beforeCommit} actions, apply the * response status and headers/cookies, and write the response body. * @param writeAction the action to write the response body (may be {@code null}) * @return a completion publisher */ protected Mono<Void> doCommit(@Nullable Supplier<? extends Mono<Void>> writeAction) { if (!this.state.compareAndSet(State.NEW, State.COMMITTING)) { return Mono.empty(); } this.commitActions.add(() -> Mono.fromRunnable(() -> { applyStatusCode(); applyHeaders(); 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(); }
/** * Apply {@link #beforeCommit(Supplier) beforeCommit} actions, apply the * response status and headers/cookies, and write the response body. * @param writeAction the action to write the response body (may be {@code null}) * @return a completion publisher */ protected Mono<Void> doCommit(@Nullable Supplier<? extends Mono<Void>> writeAction) { if (!this.state.compareAndSet(State.NEW, State.COMMITTING)) { return Mono.empty(); } this.commitActions.add(() -> Mono.fromRunnable(() -> { applyStatusCode(); applyHeaders(); 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(); }
/** * Apply {@link #beforeCommit(Supplier) beforeCommit} actions, apply the * response status and headers/cookies, and write the response body. * @param writeAction the action to write the response body (may be {@code null}) * @return a completion publisher */ protected Mono<Void> doCommit(@Nullable Supplier<? extends Mono<Void>> writeAction) { if (!this.state.compareAndSet(State.NEW, State.COMMITTING)) { return Mono.empty(); } this.commitActions.add(() -> Mono.fromRunnable(() -> { applyStatusCode(); applyHeaders(); 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(); }
/** * Apply {@link #beforeCommit(Supplier) beforeCommit} actions, apply the * response status and headers/cookies, and write the response body. * @param writeAction the action to write the response body (may be {@code null}) * @return a completion publisher */ protected Mono<Void> doCommit(@Nullable Supplier<? extends Mono<Void>> writeAction) { if (!this.state.compareAndSet(State.NEW, State.COMMITTING)) { if (logger.isDebugEnabled()) { logger.debug("Skipping doCommit (response already committed)."); } return Mono.empty(); } this.commitActions.add(() -> Mono.fromRunnable(() -> { applyStatusCode(); applyHeaders(); 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(); }