[ https://issues.apache.org/jira/browse/SPARK-40036?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Apache Spark reassigned SPARK-40036: ------------------------------------ Assignee: Apache Spark > LevelDB/RocksDBIterator.next should return false after iterator or db close > --------------------------------------------------------------------------- > > Key: SPARK-40036 > URL: https://issues.apache.org/jira/browse/SPARK-40036 > Project: Spark > Issue Type: Bug > Components: Spark Core > Affects Versions: 3.4.0 > Reporter: Yang Jie > Assignee: Apache Spark > Priority: Minor > > {code:java} > @Test > public void testHasNextAndNextAfterIteratorClose() throws Exception { > String prefix = "test_db_iter_close."; > String suffix = ".ldb"; > File path = File.createTempFile(prefix, suffix); > path.delete(); > LevelDB db = new LevelDB(path); > // Write one records for test > db.write(createCustomType1(0)); > KVStoreIterator<CustomType1> iter = > db.view(CustomType1.class).closeableIterator(); > // iter should be true > assertTrue(iter.hasNext()); > // close iter > iter.close(); > // iter.hasNext should be false after iter close > assertFalse(iter.hasNext()); > // iter.next should throw NoSuchElementException after iter close > assertThrows(NoSuchElementException.class, iter::next); > db.close(); > assertTrue(path.exists()); > FileUtils.deleteQuietly(path); > assertFalse(path.exists()); > } > @Test > public void testHasNextAndNextAfterDBClose() throws Exception { > String prefix = "test_db_db_close."; > String suffix = ".ldb"; > File path = File.createTempFile(prefix, suffix); > path.delete(); > LevelDB db = new LevelDB(path); > // Write one record for test > db.write(createCustomType1(0)); > KVStoreIterator<CustomType1> iter = > db.view(CustomType1.class).closeableIterator(); > // iter should be true > assertTrue(iter.hasNext()); > // close db > db.close(); > // iter.hasNext should be false after db close > assertFalse(iter.hasNext()); > // iter.next should throw NoSuchElementException after db close > assertThrows(NoSuchElementException.class, iter::next); > assertTrue(path.exists()); > FileUtils.deleteQuietly(path); > assertFalse(path.exists()); > } {code} > > For the above two cases, when iterator/db is closed, `hasNext` will return > true, and `next` will return the value not obtained before close. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org