From 54d28275226e0bc3b0d46142ce20f74a52e66395 Mon Sep 17 00:00:00 2001 From: Zhe Zhang Date: Tue, 12 May 2015 14:31:28 -0700 Subject: [PATCH] HDFS-8368. Erasure Coding: DFS opening a non-existent file need to be handled properly. Contributed by Rakesh R. --- .../hadoop-hdfs/CHANGES-HDFS-EC-7285.txt | 3 +++ .../main/java/org/apache/hadoop/hdfs/DFSClient.java | 12 +++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-EC-7285.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-EC-7285.txt index f026a5cde7..79ad208aaf 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-EC-7285.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-EC-7285.txt @@ -201,3 +201,6 @@ HDFS-8372. Erasure coding: compute storage type quotas for striped files, to be consistent with HDFS-8327. (Zhe Zhang via jing9) + + HDFS-8368. Erasure Coding: DFS opening a non-existent file need to be + handled properly (Rakesh R via zhz) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java index 9155b4d09e..ffeb568cff 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java @@ -1193,12 +1193,14 @@ public DFSInputStream open(String src, int buffersize, boolean verifyChecksum) // Get block info from namenode TraceScope scope = getPathTraceScope("newDFSInputStream", src); try { - ECSchema schema = getFileInfo(src).getECSchema(); - if (schema != null) { - return new DFSStripedInputStream(this, src, verifyChecksum, schema); - } else { - return new DFSInputStream(this, src, verifyChecksum); + HdfsFileStatus fileInfo = getFileInfo(src); + if (fileInfo != null) { + ECSchema schema = fileInfo.getECSchema(); + if (schema != null) { + return new DFSStripedInputStream(this, src, verifyChecksum, schema); + } } + return new DFSInputStream(this, src, verifyChecksum); } finally { scope.close(); }