LuciferYang commented on code in PR #36237:
URL: https://github.com/apache/spark/pull/36237#discussion_r851850154


##########
common/kvstore/src/test/java/org/apache/spark/util/kvstore/RocksDBSuite.java:
##########
@@ -255,12 +257,15 @@ public void testNegativeIndexValues() throws Exception {
       }
     });
 
-    List<Integer> results = StreamSupport
-      .stream(db.view(CustomType1.class).index("int").spliterator(), false)
-      .map(e -> e.num)
-      .collect(Collectors.toList());
+    try (KVStoreIterator<CustomType1> iterator =
+      db.view(CustomType1.class).index("int").closeableIterator()) {
+      List<Integer> results = StreamSupport
+        .stream(Spliterators.spliteratorUnknownSize(iterator, 0), false)
+        .map(e -> e.num)
+        .collect(Collectors.toList());
 
-    assertEquals(expected, results);
+      assertEquals(expected, results);
+    }
   }
 
   @Test

Review Comment:
   This pr clears all similar cases except `testCloseRocksDBIterator` in 
`LevelDB/RocksDBSuite` because this case seems use to check `finalize` 
mechanism.
   
   After this pr, we can consider cleaning up `finalize()` related code from 
`LevelDB/RocksDB` because the `finalize` mechanism is not recommended, and it 
has been identified as `forRemoval=true` after [Java 
18](https://openjdk.java.net/jeps/421)
   
   cc @srowen @HyukjinKwon @dongjoon-hyun 
   
   



-- 
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]

Reply via email to