Code cleanup

This commit is contained in:
Andrea Cavalli 2022-05-22 00:32:08 +02:00
parent 2e58189015
commit bff4d87164
2 changed files with 10 additions and 7 deletions

View File

@ -809,8 +809,8 @@ public class LLUtils {
public static <U> Mono<Delta<U>> mapLLDelta(Mono<LLDelta> mono,
SerializationFunction<@NotNull Buffer, @Nullable U> mapper) {
return Mono.usingWhen(mono, delta -> Mono.fromCallable(() -> {
Buffer prev = delta.previousUnsafe();
Buffer curr = delta.currentUnsafe();
try (Buffer prev = delta.previousUnsafe();
Buffer curr = delta.currentUnsafe()) {
U newPrev;
U newCurr;
if (prev != null) {
@ -824,6 +824,7 @@ public class LLUtils {
newCurr = null;
}
return new Delta<>(newPrev, newCurr);
}
}), delta -> Mono.fromRunnable(delta::close));
}

View File

@ -281,10 +281,10 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
public Mono<Void> putValue(T keySuffix, U value) {
var keyMono = Mono.fromCallable(() -> serializeKeySuffixToKey(keySuffix)).single();
var valueMono = Mono.fromCallable(() -> serializeValue(value)).single();
return dictionary
.put(keyMono, valueMono, LLDictionaryResultType.VOID)
.doOnNext(Resource::close)
.then();
return Mono.usingWhen(dictionary.put(keyMono, valueMono, LLDictionaryResultType.VOID),
v -> Mono.empty(),
v -> Mono.fromRunnable(v::close)
);
}
@Override
@ -316,7 +316,9 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
if (oldSerialized == null) {
result = updater.apply(null);
} else {
result = updater.apply(valueSerializer.deserialize(oldSerialized));
try (oldSerialized) {
result = updater.apply(valueSerializer.deserialize(oldSerialized));
}
}
if (result == null) {
return null;