Add a discard hook

This commit is contained in:
Andrea Cavalli 2021-11-09 15:57:16 +01:00
parent d4dae4667d
commit 42c4b6e651

View File

@ -419,7 +419,15 @@ public class LLLocalDictionary implements LLDictionary {
existsAlmostCertainly, UpdateAtomicResultMode.DELTA);
return ((UpdateAtomicResultDelta) result).delta();
}).onErrorMap(cause -> new IOException("Failed to read or write", cause)),
keySend -> Mono.fromRunnable(keySend::close));
keySend -> Mono.fromRunnable(keySend::close)).doOnDiscard(UpdateAtomicResult.class, uar -> {
if (uar instanceof UpdateAtomicResultDelta delta) {
delta.delta().close();
} else if (uar instanceof UpdateAtomicResultCurrent cur) {
cur.current().close();
} else if (uar instanceof UpdateAtomicResultPrevious cur) {
cur.previous().close();
}
});
}
@Override