You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by ad...@apache.org on 2022/06/24 12:42:56 UTC

[ozone] branch master updated: HDDS-6937. Close Rocks objects properly in TrashOzoneFilesystem (#3541)

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

adoroszlai 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 dbcd2c93a7 HDDS-6937. Close Rocks objects properly in TrashOzoneFilesystem (#3541)
dbcd2c93a7 is described below

commit dbcd2c93a7be5c4f5fa3786d99248ebf18c1afe8
Author: Doroszlai, Attila <64...@users.noreply.github.com>
AuthorDate: Fri Jun 24 14:42:51 2022 +0200

    HDDS-6937. Close Rocks objects properly in TrashOzoneFilesystem (#3541)
---
 .../apache/hadoop/ozone/om/TrashOzoneFileSystem.java   | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/TrashOzoneFileSystem.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/TrashOzoneFileSystem.java
index 41017f1d86..65ee17a2b0 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/TrashOzoneFileSystem.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/TrashOzoneFileSystem.java
@@ -48,6 +48,7 @@ import org.apache.ratis.protocol.RaftClientRequest;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.Closeable;
 import java.io.IOException;
 import java.net.InetAddress;
 import java.net.URI;
@@ -164,8 +165,9 @@ public class TrashOzoneFileSystem extends FileSystem {
         equals(dstPath.getBucketName()));
     Preconditions.checkArgument(srcPath.getTrashRoot().
         toString().equals(dstPath.getTrashRoot().toString()));
-    RenameIterator iterator = new RenameIterator(src, dst);
-    iterator.iterate();
+    try (RenameIterator iterator = new RenameIterator(src, dst)) {
+      iterator.iterate();
+    }
     return true;
   }
 
@@ -194,8 +196,9 @@ public class TrashOzoneFileSystem extends FileSystem {
     if (bucket.getBucketLayout().isFileSystemOptimized()) {
       return deleteFSO(srcPath);
     }
-    DeleteIterator iterator = new DeleteIterator(path, true);
-    iterator.iterate();
+    try (DeleteIterator iterator = new DeleteIterator(path, true)) {
+      iterator.iterate();
+    }
     return true;
   }
 
@@ -342,7 +345,7 @@ public class TrashOzoneFileSystem extends FileSystem {
     }
   }
 
-  private abstract class OzoneListingIterator {
+  private abstract class OzoneListingIterator implements Closeable {
     private final Path path;
     private final FileStatus status;
     private String pathKey;
@@ -420,6 +423,11 @@ public class TrashOzoneFileSystem extends FileSystem {
     FileStatus getStatus() {
       return status;
     }
+
+    @Override
+    public void close() throws IOException {
+      keyIterator.close();
+    }
   }
 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org