You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uniffle.apache.org by ck...@apache.org on 2023/02/02 09:19:46 UTC

[incubator-uniffle] branch master updated: Result of mkdirs() is ignored in LocalFileWriteHandler#createBasePath() (#537)

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

ckj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git


The following commit(s) were added to refs/heads/master by this push:
     new 6f66f108 Result of mkdirs() is ignored in LocalFileWriteHandler#createBasePath() (#537)
6f66f108 is described below

commit 6f66f1089a94caa1f4fa652bf6b169272b1aa3bf
Author: Kaijie Chen <ck...@apache.org>
AuthorDate: Thu Feb 2 17:19:40 2023 +0800

    Result of mkdirs() is ignored in LocalFileWriteHandler#createBasePath() (#537)
    
    ### What changes were proposed in this pull request?
    
    Fix error handling in `LocalFileWriteHandler#createBasePath()`.
    Throw a `RssException` in case of failure.
    
    ### Why are the changes needed?
    
    The return value of `baseFolder.mkdirs()` was ignored.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    CI.
---
 .../storage/handler/impl/LocalFileWriteHandler.java | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/storage/src/main/java/org/apache/uniffle/storage/handler/impl/LocalFileWriteHandler.java b/storage/src/main/java/org/apache/uniffle/storage/handler/impl/LocalFileWriteHandler.java
index fa466a08..1eb1a885 100644
--- a/storage/src/main/java/org/apache/uniffle/storage/handler/impl/LocalFileWriteHandler.java
+++ b/storage/src/main/java/org/apache/uniffle/storage/handler/impl/LocalFileWriteHandler.java
@@ -19,6 +19,7 @@ package org.apache.uniffle.storage.handler.impl;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
 import java.util.List;
 
 import com.google.common.annotations.VisibleForTesting;
@@ -26,6 +27,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.uniffle.common.ShufflePartitionedBlock;
+import org.apache.uniffle.common.exception.RssException;
 import org.apache.uniffle.storage.common.FileBasedShuffleSegment;
 import org.apache.uniffle.storage.handler.api.ShuffleWriteHandler;
 import org.apache.uniffle.storage.util.ShuffleStorageUtils;
@@ -52,18 +54,13 @@ public class LocalFileWriteHandler implements ShuffleWriteHandler {
 
   private void createBasePath() {
     File baseFolder = new File(basePath);
-    // check if shuffle folder exist
-    if (!baseFolder.exists()) {
-      try {
-        // try to create folder, it may be created by other Shuffle Server
-        baseFolder.mkdirs();
-      } catch (SecurityException e) {
-        // if folder exist, ignore the exception
-        if (!baseFolder.exists()) {
-          LOG.error("Can't create shuffle folder:" + basePath, e);
-          throw e;
-        }
-      }
+    if (baseFolder.isDirectory()) {
+      return;
+    }
+    try {
+      Files.createDirectories(baseFolder.toPath());
+    } catch (IOException e) {
+      throw new RssException("Failed to create shuffle folder: " + basePath, e);
     }
   }