flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ches...@apache.org
Subject [4/4] flink git commit: [FLINK-5147] Prevent NPE in LocalFS#delete()
Date Mon, 12 Dec 2016 14:01:31 GMT
[FLINK-5147] Prevent NPE in LocalFS#delete()

This closes #2859.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/47db9cb1
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/47db9cb1
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/47db9cb1

Branch: refs/heads/master
Commit: 47db9cb1a867870a8da0b403e0ec217ac461ba04
Parents: dc5dd51
Author: zentol <chesnay@apache.org>
Authored: Wed Nov 23 15:37:06 2016 +0100
Committer: zentol <chesnay@apache.org>
Committed: Mon Dec 12 12:45:51 2016 +0100

----------------------------------------------------------------------
 .../org/apache/flink/core/fs/local/LocalFileSystem.java     | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/47db9cb1/flink-core/src/main/java/org/apache/flink/core/fs/local/LocalFileSystem.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/core/fs/local/LocalFileSystem.java
b/flink-core/src/main/java/org/apache/flink/core/fs/local/LocalFileSystem.java
index 3aaa85f..7ad68b3 100644
--- a/flink-core/src/main/java/org/apache/flink/core/fs/local/LocalFileSystem.java
+++ b/flink-core/src/main/java/org/apache/flink/core/fs/local/LocalFileSystem.java
@@ -184,8 +184,13 @@ public class LocalFileSystem extends FileSystem {
 		final File file = pathToFile(f);
 		if (file.isFile()) {
 			return file.delete();
-		} else if ((!recursive) && file.isDirectory() && (file.listFiles().length
!= 0)) {
-			throw new IOException("Directory " + file.toString() + " is not empty");
+		} else if ((!recursive) && file.isDirectory()) {
+			File[] containedFiles = file.listFiles();
+			if (containedFiles == null) {
+				throw new IOException("Directory " + file.toString() + " does not exist or an I/O error
occurred");
+			} else if (containedFiles.length != 0) {
+				throw new IOException("Directory " + file.toString() + " is not empty");
+			}
 		}
 
 		return delete(file);


Mime
View raw message