You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ch...@apache.org on 2018/09/24 11:14:14 UTC

[flink] branch master updated: [FLINK-10376][runtime] Use Files#createDirectories in BlobUtils

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 8bd9436  [FLINK-10376][runtime] Use Files#createDirectories in BlobUtils
8bd9436 is described below

commit 8bd9436aaac3e222cac0668820f15245deb4fc49
Author: Tzu-Li "tison" Chen <wa...@gmail.com>
AuthorDate: Mon Sep 24 19:14:06 2018 +0800

    [FLINK-10376][runtime] Use Files#createDirectories in BlobUtils
---
 .../org/apache/flink/runtime/blob/BlobUtils.java   | 22 ++--------------------
 .../flink/runtime/blob/BlobServerPutTest.java      |  3 +--
 2 files changed, 3 insertions(+), 22 deletions(-)

diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/blob/BlobUtils.java b/flink-runtime/src/main/java/org/apache/flink/runtime/blob/BlobUtils.java
index e1caa9c..6c53ffb 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/blob/BlobUtils.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/blob/BlobUtils.java
@@ -188,30 +188,12 @@ public class BlobUtils {
 	static File getIncomingDirectory(File storageDir) throws IOException {
 		final File incomingDir = new File(storageDir, "incoming");
 
-		mkdirTolerateExisting(incomingDir);
+		Files.createDirectories(incomingDir.toPath());
 
 		return incomingDir;
 	}
 
 	/**
-	 * Makes sure a given directory exists by creating it if necessary.
-	 *
-	 * @param dir
-	 * 		directory to create
-	 *
-	 * @throws IOException
-	 * 		if creating the directory fails
-	 */
-	private static void mkdirTolerateExisting(final File dir) throws IOException {
-		// note: thread-safe create should try to mkdir first and then ignore the case that the
-		//       directory already existed
-		if (!dir.mkdirs() && !dir.exists()) {
-			throw new IOException(
-				"Cannot create directory '" + dir.getAbsolutePath() + "'.");
-		}
-	}
-
-	/**
 	 * Returns the (designated) physical storage location of the BLOB with the given key.
 	 *
 	 * @param storageDir
@@ -230,7 +212,7 @@ public class BlobUtils {
 			File storageDir, @Nullable JobID jobId, BlobKey key) throws IOException {
 		File file = new File(getStorageLocationPath(storageDir.getAbsolutePath(), jobId, key));
 
-		mkdirTolerateExisting(file.getParentFile());
+		Files.createDirectories(file.getParentFile().toPath());
 
 		return file;
 	}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobServerPutTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobServerPutTest.java
index 202d87e..db368aa 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobServerPutTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobServerPutTest.java
@@ -492,8 +492,7 @@ public class BlobServerPutTest extends TestLogger {
 			rnd.nextBytes(data);
 
 			// upload the file to the server directly
-			exception.expect(IOException.class);
-			exception.expectMessage("Cannot create directory ");
+			exception.expect(AccessDeniedException.class);
 
 			put(server, jobId, data, blobType);