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 9cec5d1..87cf27b 100644 --- a/src/main/java/it/cavallium/rockserver/core/impl/EmbeddedDB.java +++ b/src/main/java/it/cavallium/rockserver/core/impl/EmbeddedDB.java @@ -440,6 +440,7 @@ public class EmbeddedDB implements RocksDBSyncAPI, Closeable { try { var cf = new CompletableFuture(); batchPublisher.subscribe(new Subscriber<>() { + private boolean stopped; private Subscription subscription; private ColumnInstance col; private ArrayList refs; @@ -476,6 +477,9 @@ public class EmbeddedDB implements RocksDBSyncAPI, Closeable { @Override public void onNext(KVBatch kvBatch) { + if (stopped) { + return; + } var keyIt = kvBatch.keys().iterator(); var valueIt = kvBatch.values().iterator(); try (var arena = Arena.ofConfined()) { @@ -516,6 +520,7 @@ public class EmbeddedDB implements RocksDBSyncAPI, Closeable { } private void doFinally() { + stopped = true; for (int i = refs.size() - 1; i >= 0; i--) { try { var c = refs.get(i); diff --git a/src/main/java/it/cavallium/rockserver/core/impl/rocksdb/SSTWriter.java b/src/main/java/it/cavallium/rockserver/core/impl/rocksdb/SSTWriter.java index 80eaa65..6f1cee3 100644 --- a/src/main/java/it/cavallium/rockserver/core/impl/rocksdb/SSTWriter.java +++ b/src/main/java/it/cavallium/rockserver/core/impl/rocksdb/SSTWriter.java @@ -85,7 +85,6 @@ public record SSTWriter(RocksDB db, it.cavallium.rockserver.core.impl.ColumnInst public void put(byte[] key, byte[] value) throws RocksDBException { try { - checkOwningHandle(); sstFileWriter.put(key, value); } catch (org.rocksdb.RocksDBException e) { throw RocksDBException.of(RocksDBException.RocksDBErrorType.PUT_UNKNOWN_ERROR, e); @@ -94,7 +93,6 @@ public record SSTWriter(RocksDB db, it.cavallium.rockserver.core.impl.ColumnInst public void put(ByteBuffer key, ByteBuffer value) throws RocksDBException { try { - checkOwningHandle(); sstFileWriter.put(key, value); } catch (org.rocksdb.RocksDBException e) { throw RocksDBException.of(RocksDBException.RocksDBErrorType.PUT_UNKNOWN_ERROR, e);