From c5d0adc7a884f49d05002afd97b0aaf70522d7ac Mon Sep 17 00:00:00 2001 From: Alexander Lavrukov Date: Mon, 4 Mar 2024 21:26:55 +0300 Subject: [PATCH] spliterator-bugfix: Spliterator fix --- .../main/java/tech/ydb/yoj/repository/ydb/YdbSpliterator.java | 4 ++++ .../main/java/tech/ydb/yoj/repository/ydb/YdbSpliterator.java | 4 ++++ 2 files changed, 8 insertions(+) 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;