LuciferYang commented on code in PR #43502:
URL: https://github.com/apache/spark/pull/43502#discussion_r1372643667
##########
common/kvstore/src/main/java/org/apache/spark/util/kvstore/LevelDBIterator.java:
##########
@@ -280,4 +285,24 @@ static int compare(byte[] a, byte[] b) {
return a.length - b.length;
}
+ private record ResourceCleaner(DBIterator dbIterator, LevelDB levelDB)
implements Runnable {
+ @Override
+ public void run() {
+ levelDB.getIteratorTracker().removeIf(ref -> {
+ LevelDBIterator<?> levelDBIterator = ref.get();
+ return levelDBIterator != null &&
dbIterator.equals(levelDBIterator.it);
+ });
+ synchronized (levelDB.getLevelDB()) {
+ DB _db = levelDB.getLevelDB().get();
+ if (_db == null) {
Review Comment:
What are the advantages compared to
```java
if (_db != null) {
try {
dbIterator.close();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
```
--
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]