diff --git a/repository-ydb-v1/src/main/java/tech/ydb/yoj/repository/ydb/YdbSpliterator.java b/repository-ydb-v1/src/main/java/tech/ydb/yoj/repository/ydb/YdbSpliterator.java index edad3f76..316c5d2c 100644 --- a/repository-ydb-v1/src/main/java/tech/ydb/yoj/repository/ydb/YdbSpliterator.java +++ b/repository-ydb-v1/src/main/java/tech/ydb/yoj/repository/ydb/YdbSpliterator.java @@ -119,6 +119,10 @@ private QueueValue poll() { @Override // (stream thread) called from stream engine for get new value. public boolean tryAdvance(Consumer action) { + if (closed) { + throw new IllegalStateException("Can't use closed YdbSpliterator"); + } + // Stream API can call tryAdvance() once again even if tryAdvance() returned false if (endData) { return false; diff --git a/repository-ydb-v2/src/main/java/tech/ydb/yoj/repository/ydb/YdbSpliterator.java b/repository-ydb-v2/src/main/java/tech/ydb/yoj/repository/ydb/YdbSpliterator.java index 82fff1d6..c0ff42ca 100644 --- a/repository-ydb-v2/src/main/java/tech/ydb/yoj/repository/ydb/YdbSpliterator.java +++ b/repository-ydb-v2/src/main/java/tech/ydb/yoj/repository/ydb/YdbSpliterator.java @@ -120,6 +120,10 @@ private QueueValue poll() { @Override // (stream thread) called from stream engine for get new value. public boolean tryAdvance(Consumer action) { + if (closed) { + throw new IllegalStateException("Can't use closed YdbSpliterator"); + } + // Stream API can call tryAdvance() once again even if tryAdvance() returned false if (endData) { return false;