Copy map before writing to avoid errors

This commit is contained in:
Andrea Cavalli 2021-06-30 10:58:49 +02:00
parent 3758d06853
commit b567f9f320

View File

@ -171,7 +171,7 @@ public interface DatabaseStageMap<T, U, US extends DatabaseStage<U>> extends Dat
@Override
default Mono<Map<T, U>> setAndGetPrevious(Map<T, U> value) {
return this
.setAllValuesAndGetPrevious(Flux.fromIterable(Collections.unmodifiableMap(value).entrySet()))
.setAllValuesAndGetPrevious(Flux.fromIterable(Map.copyOf(value).entrySet()))
.collectMap(Entry::getKey, Entry::getValue, HashMap::new);
}
@ -207,7 +207,7 @@ public interface DatabaseStageMap<T, U, US extends DatabaseStage<U>> extends Dat
})
.flatMap(result -> Mono
.justOrEmpty(result.getT2())
.flatMap(values -> this.setAllValues(Flux.fromIterable(Collections.unmodifiableMap(values).entrySet())))
.flatMap(values -> this.setAllValues(Flux.fromIterable(Map.copyOf(values).entrySet())))
.thenReturn(new Delta<>(result.getT1().orElse(null), result.getT2().orElse(null)))
);
} else if (updateMode == UpdateMode.ALLOW) {