zentol closed pull request #6721: [FLINK-10376] [tests] Replace
mkdirTolerateExisting by thread safe Files#createDirectories
URL: https://github.com/apache/flink/pull/6721
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
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 a61d679a156..7610817d7c1 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
@@ -192,29 +192,11 @@ static File initLocalStorageDirectory(Configuration
config) throws IOException {
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.
*
@@ -234,7 +216,7 @@ static File getStorageLocation(
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 202d87e0c63..db368aa02e7 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 @@ private void testPutBufferFails(@Nullable final JobID
jobId, BlobKey.BlobType bl
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);
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services