This is an automated email from the ASF dual-hosted git repository.

sammichen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 2ba8bb71f1 HDDS-7643. rocksdb iterator is not closed properly (#4084)
2ba8bb71f1 is described below

commit 2ba8bb71f128ec619c5bed9b6303394e8677bf53
Author: Sumit Agrawal <[email protected]>
AuthorDate: Thu Dec 15 06:44:05 2022 +0530

    HDDS-7643. rocksdb iterator is not closed properly (#4084)
---
 .../org/apache/hadoop/ozone/om/KeyManagerImpl.java | 25 ++++++++++++----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
index f41dc96e1b..f500c9edd9 100644
--- 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
+++ 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
@@ -1318,17 +1318,20 @@ public class KeyManagerImpl implements KeyManager {
     OmKeyInfo fakeDirKeyInfo = null;
     String dirKey = OzoneFSUtils.addTrailingSlashIfNeeded(keyName);
     String fileKeyBytes = metadataManager.getOzoneKey(volume, bucket, keyName);
-    Table.KeyValue<String, OmKeyInfo> keyValue =
-            metadataManager.getKeyTable(layout).iterator()
-                .seek(OzoneFSUtils.addTrailingSlashIfNeeded(fileKeyBytes));
-
-    if (keyValue != null) {
-      Path fullPath = Paths.get(keyValue.getValue().getKeyName());
-      Path subPath = Paths.get(dirKey);
-      OmKeyInfo omKeyInfo = keyValue.getValue();
-      if (fullPath.startsWith(subPath)) {
-        // create fake directory
-        fakeDirKeyInfo = createDirectoryKey(omKeyInfo, dirKey);
+    try (TableIterator<String, ? extends Table.KeyValue<String, OmKeyInfo>>
+             keyTblItr = metadataManager.getKeyTable(layout).iterator()) {
+      Table.KeyValue<String, OmKeyInfo> keyValue =
+          keyTblItr
+              .seek(OzoneFSUtils.addTrailingSlashIfNeeded(fileKeyBytes));
+
+      if (keyValue != null) {
+        Path fullPath = Paths.get(keyValue.getValue().getKeyName());
+        Path subPath = Paths.get(dirKey);
+        OmKeyInfo omKeyInfo = keyValue.getValue();
+        if (fullPath.startsWith(subPath)) {
+          // create fake directory
+          fakeDirKeyInfo = createDirectoryKey(omKeyInfo, dirKey);
+        }
       }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to