smengcl commented on code in PR #5751:
URL: https://github.com/apache/ozone/pull/5751#discussion_r1425776306


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotCache.java:
##########
@@ -230,21 +231,19 @@ public ReferenceCounted<IOmMetadataReader, SnapshotCache> 
get(String key,
    * @param key snapshot table key
    */
   public void release(String key) {
-    dbMap.compute(key, (k, v) -> {
-      if (v == null) {
-        throw new IllegalArgumentException(
-            "Key '" + key + "' does not exist in cache");
-      }
+    ReferenceCounted<IOmMetadataReader, SnapshotCache>
+        rcOmSnapshot = dbMap.get(key);
+    if (rcOmSnapshot == null) {
+      throw new IllegalArgumentException(
+          "Key '" + key + "' does not exist in cache");
+    }
 
-      if (v.decrementRefCount() == 0L) {
-        synchronized (pendingEvictionList) {
-          // v is eligible to be evicted and closed
-          pendingEvictionList.add(v);
-        }
+    if (rcOmSnapshot.decrementRefCount() == 0L) {
+      synchronized (pendingEvictionList) {
+        // v is eligible to be evicted and closed
+        pendingEvictionList.add(rcOmSnapshot);
       }
-
-      return v;
-    });
+    }

Review Comment:
   @aswinshakil Indeed `SnapshotCache#release` is not called directly right now 
and is only kept to conform to Guava cache convention (and just in case we 
would need it). Ref count is currently decremented by `ReferenceCounted#close`.



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