Skip to content

Commit

Permalink
A bit more test of Java API on closed iterators
Browse files Browse the repository at this point in the history
  • Loading branch information
alanpaxton committed Dec 2, 2024
1 parent 2c068ff commit 7aa0770
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions java/src/test/java/org/rocksdb/IteratorClosedDBTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,21 @@ public void shouldNotCrashJavaRocks() throws RocksDBException {
it.seekToFirst();
assertThat(it.isValid()).isTrue();

byte[] valueOK = it.value();
assertThat(valueOK).isEqualTo(value);

// Close should work because iterator references are now cleaned up
// Previously would have thrown an exception here (assertion failure in C++) -
// when built with DEBUG_LEVEL=1
// Because the outstanding iterator has a reference to the column family which is being closed
db.close();

try {
byte[] valueShouldAssert = it.value();
throw new RuntimeException("it.value() should cause an assertion");
} catch (AssertionError ignored) {
}

// should assert
try {
boolean isValidShouldAssert = it.isValid();
Expand Down

0 comments on commit 7aa0770

Please sign in to comment.