You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ta...@apache.org on 2021/05/12 15:06:32 UTC
[hadoop] branch trunk updated: HADOOP-17689. Avoid Potential NPE in
org.apache.hadoop.fs (#3008)
This is an automated email from the ASF dual-hosted git repository.
tasanuma pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new fdd20a3 HADOOP-17689. Avoid Potential NPE in org.apache.hadoop.fs (#3008)
fdd20a3 is described below
commit fdd20a3cf4cd9073f443b2bf07eef14f454d4c33
Author: Viraj Jasani <vj...@apache.org>
AuthorDate: Wed May 12 20:35:58 2021 +0530
HADOOP-17689. Avoid Potential NPE in org.apache.hadoop.fs (#3008)
Signed-off-by: Takanobu Asanuma <ta...@apache.org>
---
.../src/main/java/org/apache/hadoop/fs/DelegateToFileSystem.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegateToFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegateToFileSystem.java
index 3a13978..cdb4f3e 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegateToFileSystem.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegateToFileSystem.java
@@ -24,6 +24,7 @@ import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -90,7 +91,11 @@ public abstract class DelegateToFileSystem extends AbstractFileSystem {
if (!createParent) { // parent must exist.
// since this.create makes parent dirs automatically
// we must throw exception if parent does not exist.
- final FileStatus stat = getFileStatus(f.getParent());
+ Optional<Path> parentPath = f.getOptionalParentPath();
+ if (!parentPath.isPresent()) {
+ throw new FileNotFoundException("Missing parent:" + f);
+ }
+ final FileStatus stat = getFileStatus(parentPath.get());
if (stat == null) {
throw new FileNotFoundException("Missing parent:" + f);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org