You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/07/31 08:11:23 UTC

[GitHub] [ozone] adoroszlai commented on a change in pull request #2481: HDDS-5524. Use try-with-resources to properly close resources in DirectoryServerSource.java

adoroszlai commented on a change in pull request #2481:
URL: https://github.com/apache/ozone/pull/2481#discussion_r680327506



##########
File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/stream/DirectoryServerSource.java
##########
@@ -41,18 +42,19 @@ public DirectoryServerSource(Path root) {
    * @param id name of the subdirectory to replitace relative to root.
    */
   public Map<String, Path> getFilesToStream(String id)
-      throws InterruptedException {
+          throws InterruptedException {
     Map<String, Path> files = new HashMap<>();
     final Path streamingDir = root.resolve(id);
     try {
-      Files.walk(streamingDir)
-          .filter(Files::isRegularFile)
-          .forEach(path -> {
-            files.put(root.relativize(path).toString(), path);
-          });
+      try (Stream<Path> list = Files.walk(streamingDir)
+              .filter(Files::isRegularFile)) {
+        list.forEach(path -> {
+          files.put(root.relativize(path).toString(), path);
+        });
+      }
     } catch (IOException e) {
       throw new StreamingException("Couldn't read directory for streaming: " +
-          streamingDir, e);
+              streamingDir, e);

Review comment:
       Nit: unnecessary whitespace change.

##########
File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/stream/DirectoryServerSource.java
##########
@@ -41,18 +42,19 @@ public DirectoryServerSource(Path root) {
    * @param id name of the subdirectory to replitace relative to root.
    */
   public Map<String, Path> getFilesToStream(String id)
-      throws InterruptedException {
+          throws InterruptedException {

Review comment:
       Nit: unnecessary whitespace change.

##########
File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/stream/DirectoryServerSource.java
##########
@@ -41,18 +42,19 @@ public DirectoryServerSource(Path root) {
    * @param id name of the subdirectory to replitace relative to root.
    */
   public Map<String, Path> getFilesToStream(String id)
-      throws InterruptedException {
+          throws InterruptedException {
     Map<String, Path> files = new HashMap<>();
     final Path streamingDir = root.resolve(id);
     try {
-      Files.walk(streamingDir)
-          .filter(Files::isRegularFile)
-          .forEach(path -> {
-            files.put(root.relativize(path).toString(), path);
-          });
+      try (Stream<Path> list = Files.walk(streamingDir)

Review comment:
       Can you please merge these two `try` blocks?




-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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