/** * Apply {@link #beforeCommit(Supplier) beforeCommit} actions, apply the * request headers/cookies, and write the request body. * @param writeAction the action to write the request body (may be {@code null}) * @return a completion publisher */ protected Mono<Void> doCommit(@Nullable Supplier<? extends Publisher<Void>> writeAction) { if (!this.state.compareAndSet(State.NEW, State.COMMITTING)) { return Mono.empty(); } this.commitActions.add(() -> Mono.fromRunnable(() -> { applyHeaders(); applyCookies(); this.state.set(State.COMMITTED); })); if (writeAction != null) { this.commitActions.add(writeAction); } List<? extends Publisher<Void>> actions = this.commitActions.stream() .map(Supplier::get).collect(Collectors.toList()); return Flux.concat(actions).then(); }
/** * Apply {@link #beforeCommit(Supplier) beforeCommit} actions, apply the * request headers/cookies, and write the request body. * @param writeAction the action to write the request body (may be {@code null}) * @return a completion publisher */ protected Mono<Void> doCommit(@Nullable Supplier<? extends Publisher<Void>> writeAction) { if (!this.state.compareAndSet(State.NEW, State.COMMITTING)) { return Mono.empty(); } this.commitActions.add(() -> Mono.fromRunnable(() -> { applyHeaders(); applyCookies(); this.state.set(State.COMMITTED); })); if (writeAction != null) { this.commitActions.add(writeAction); } List<? extends Publisher<Void>> actions = this.commitActions.stream() .map(Supplier::get).collect(Collectors.toList()); return Flux.concat(actions).then(); }
/** * Apply {@link #beforeCommit(Supplier) beforeCommit} actions, apply the * request headers/cookies, and write the request body. * @param writeAction the action to write the request body (may be {@code null}) * @return a completion publisher */ protected Mono<Void> doCommit(@Nullable Supplier<? extends Publisher<Void>> writeAction) { if (!this.state.compareAndSet(State.NEW, State.COMMITTING)) { return Mono.empty(); } this.commitActions.add(() -> Mono.fromRunnable(() -> { applyHeaders(); applyCookies(); this.state.set(State.COMMITTED); })); if (writeAction != null) { this.commitActions.add(writeAction); } List<? extends Publisher<Void>> actions = this.commitActions.stream() .map(Supplier::get).collect(Collectors.toList()); return Flux.concat(actions).then(); }
/** * Apply {@link #beforeCommit(Supplier) beforeCommit} actions, apply the * request headers/cookies, and write the request body. * @param writeAction the action to write the request body (may be {@code null}) * @return a completion publisher */ protected Mono<Void> doCommit(@Nullable Supplier<? extends Publisher<Void>> writeAction) { if (!this.state.compareAndSet(State.NEW, State.COMMITTING)) { return Mono.empty(); } this.commitActions.add(() -> Mono.fromRunnable(() -> { applyHeaders(); applyCookies(); this.state.set(State.COMMITTED); })); if (writeAction != null) { this.commitActions.add(writeAction); } List<? extends Publisher<Void>> actions = this.commitActions.stream() .map(Supplier::get).collect(Collectors.toList()); return Flux.concat(actions).then(); }