ctubbsii commented on code in PR #4909:
URL: https://github.com/apache/accumulo/pull/4909#discussion_r1767492112


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/NativeMap.java:
##########
@@ -304,7 +304,13 @@ private class NMIterator implements 
Iterator<Map.Entry<Key,Value>> {
       hasNext = nmiPointer != 0;
 
       nmiPtr.set(nmiPointer);
-      cleanableNMI = NativeMapCleanerUtil.deleteNMIterator(this, nmiPtr);
+      if (nmiPointer == 0) {
+        // registering a cleaner takes resources and may lock, so only bother 
registering if there
+        // is something to delete
+        cleanableNMI = null;
+      } else {
+        cleanableNMI = NativeMapCleanerUtil.deleteNMIterator(this, nmiPtr);
+      }

Review Comment:
   Implementation looks fine, but I think it can be written more concisely as:
   
   ```suggestion
         // avoid registering a cleanable if there's nothing to delete
         cleanableNMI = hasNext ? NativeMapCleanerUtil.deleteNMIterator(this, 
nmiPtr) : null;
   ```



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

Reply via email to