Gargi-jais11 commented on code in PR #9904:
URL: https://github.com/apache/ozone/pull/9904#discussion_r2929204888


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RDBStoreAbstractIterator.java:
##########


Review Comment:
   I agree that throwing an exception is safer than returning null.
   But we need to fix the above idea to :
   ```
   @Override
   public final Table.KeyValue<RAW, RAW> next() {
     setCurrentEntry();
     if (currentEntry != null) {
       if (!isDbClosed()) {
         rocksDBIterator.get().next();
       }
       return currentEntry;  // Return in BOTH cases - avoids throw when DB 
closed mid-race
     }
     throw new NoSuchElementException("RocksDB Store has no more elements");
   }
   ```
   When `currentEntry != null` and the DB is closed, do not call 
`rocksDBIterator.get().next()` (avoid native calls).
   But it still need to return `currentEntry` in that case, otherwise the code 
falls through and throws `NoSuchElementException`, which doesn’t fix the race.



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