Skip to content

Commit

Permalink
Java: Fix reactor flatMap producing out of order results (#1849)
Browse files Browse the repository at this point in the history
Fixes a concurrency bug, `Flux.flatMap` will return the first available
result rather than keeping the results in order, changed to concatMap
  • Loading branch information
johnoliver committed Jul 8, 2023
1 parent 0e63f3b commit 470dae2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public Mono<SKContext> aggregatePartitionedResultsAsync(
// function
BiFunction<Flux<SKContext>, String, Flux<SKContext>> executeNextChunk =
(contextInput, input) ->
contextInput.flatMap(
contextInput.concatMap(
newContext -> {
SKContext updated = newContext.update(input);
return invokeAsync(updated, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public Mono<String> renderAsync(String templateText, SKContext context) {
/// <inheritdoc/>
public Mono<String> renderAsync(List<Block> blocks, SKContext context) {
return Flux.fromIterable(blocks)
.flatMap(
.concatMap(
block -> {
if (block instanceof TextRendering) {
return Mono.just(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Mono<SKContext> rememberFunctionsAsync(List<SKFunction<?>> availableFunctions) {
}

return Flux.fromIterable(availableFunctions)
.flatMap(
.concatMap(
function -> {
String functionName = function.toFullyQualifiedName();
String key = functionName;
Expand Down

0 comments on commit 470dae2

Please sign in to comment.