LuciferYang commented on code in PR #37471:
URL: https://github.com/apache/spark/pull/37471#discussion_r943065200
##########
common/kvstore/src/test/java/org/apache/spark/util/kvstore/LevelDBSuite.java:
##########
@@ -305,6 +305,84 @@ public void testCloseLevelDBIterator() throws Exception {
assertTrue(!dbPathForCloseTest.exists());
}
+ @Test
+ public void testHasNextAfterIteratorClose() throws Exception {
+ 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());
Review Comment:
`iter.hasNext()` return `true` before this pr
##########
common/kvstore/src/test/java/org/apache/spark/util/kvstore/LevelDBSuite.java:
##########
@@ -305,6 +305,84 @@ public void testCloseLevelDBIterator() throws Exception {
assertTrue(!dbPathForCloseTest.exists());
}
+ @Test
+ public void testHasNextAfterIteratorClose() throws Exception {
+ 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());
+ }
+
+ @Test
+ public void testHasNextAfterDBClose() throws Exception {
+ 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());
Review Comment:
`iter.hasNext()` return `true` before this pr
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]