[ 
https://issues.apache.org/jira/browse/HDFS-6143?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13963576#comment-13963576
 ] 

Gera Shegalov commented on HDFS-6143:
-------------------------------------

[~daryn], I think putting calling {{getFileStatus}} in open to get FNF, and 
keep the old lazy open will have the same effect.

{code}
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java
 b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/
index bdf744a..bad1534 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java
@@ -898,6 +898,7 @@ public boolean delete(Path f, boolean recursive) throws 
IOException {
   @Override
   public FSDataInputStream open(final Path f, final int buffersize
       ) throws IOException {
+    getFileStatus(f);
     statistics.incrementReadOps(1);
     final HttpOpParam.Op op = GetOpParam.Op.OPEN;
     final URL url = toUrl(op, f, new BufferSizeParam(buffersize));
{code}


> WebHdfsFileSystem open should throw FileNotFoundException for non-existing 
> paths
> --------------------------------------------------------------------------------
>
>                 Key: HDFS-6143
>                 URL: https://issues.apache.org/jira/browse/HDFS-6143
>             Project: Hadoop HDFS
>          Issue Type: Bug
>    Affects Versions: 2.3.0
>            Reporter: Gera Shegalov
>            Assignee: Gera Shegalov
>            Priority: Blocker
>             Fix For: 2.5.0
>
>         Attachments: HDFS-6143-branch-2.4.0.v01.patch, 
> HDFS-6143-trunk-after-HDFS-5570.v01.patch, 
> HDFS-6143-trunk-after-HDFS-5570.v02.patch, HDFS-6143.v01.patch, 
> HDFS-6143.v02.patch, HDFS-6143.v03.patch, HDFS-6143.v04.patch, 
> HDFS-6143.v04.patch, HDFS-6143.v05.patch, HDFS-6143.v06.patch
>
>
> WebHdfsFileSystem.open and HftpFileSystem.open incorrectly handles 
> non-existing paths. 
> - 'open', does not really open anything, i.e., it does not contact the 
> server, and therefore cannot discover FileNotFound, it's deferred until next 
> read. It's counterintuitive and not how local FS or HDFS work. In POSIX you 
> get ENOENT on open. 
> [LzoInputFormat.getSplits|https://github.com/kevinweil/elephant-bird/blob/master/core/src/main/java/com/twitter/elephantbird/mapreduce/input/LzoInputFormat.java]
>  is an example of the code that's broken because of this.
> - On the server side, FileDataServlet incorrectly sends SC_BAD_REQUEST 
> instead of SC_NOT_FOUND for non-exitsing paths



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to