From 4f4533d4343c9b48b96b3d226953a171330cba0f Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Thu, 24 Oct 2024 03:25:42 +0200 Subject: [PATCH] Fix crashes --- .../rockserver/core/impl/EmbeddedDB.java | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/java/it/cavallium/rockserver/core/impl/EmbeddedDB.java b/src/main/java/it/cavallium/rockserver/core/impl/EmbeddedDB.java index a6e93cf..eaa1da2 100644 --- a/src/main/java/it/cavallium/rockserver/core/impl/EmbeddedDB.java +++ b/src/main/java/it/cavallium/rockserver/core/impl/EmbeddedDB.java @@ -1135,27 +1135,27 @@ public class EmbeddedDB implements RocksDBSyncAPI, Closeable { throw ex; } }, res -> Flux.generate(() -> { - if (!reverse) { - res.it.seekToFirst(); - } else { - res.it.seekToLast(); - } - return res.it; + if (!reverse) { + res.it.seekToFirst(); + } else { + res.it.seekToLast(); + } + return res.it; }, (it, sink) -> { - if (!it.isValid()) { - sink.complete(); - } else { - var calculatedKey = toMemorySegment(arena, it.key()); - var calculatedValue = res.col.schema().hasValue() ? toMemorySegment(it.value()) : MemorySegment.NULL; - //noinspection unchecked - sink.next((T) decodeKVNoBuckets(arena, res.col, calculatedKey, calculatedValue)); - if (!reverse) { - res.it.next(); - } else { - res.it.prev(); - } - } - return it; + if (!it.isValid()) { + sink.complete(); + } else { + var calculatedKey = toMemorySegment(arena, it.key()); + var calculatedValue = res.col.schema().hasValue() ? toMemorySegment(it.value()) : MemorySegment.NULL; + if (!reverse) { + res.it.next(); + } else { + res.it.prev(); + } + //noinspection unchecked + sink.next((T) decodeKVNoBuckets(arena, res.col, calculatedKey, calculatedValue)); + } + return it; }), Resources::close) .subscribeOn(Schedulers.boundedElastic()) .doFirst(ops::beginOp)