diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 1f6b8874ec..0c0cbb25d3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -317,6 +317,9 @@ Release 2.5.0 - UNRELEASED HDFS-6180. dead node count / listing is very broken in JMX and old GUI. (wheat9) + HDFS-6143. WebHdfsFileSystem open should throw FileNotFoundException for + non-existing paths. (Gera Shegalov via wheat9) + Release 2.4.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/ByteRangeInputStream.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/ByteRangeInputStream.java index fd274b778a..395c9f6088 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/ByteRangeInputStream.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/ByteRangeInputStream.java @@ -83,9 +83,10 @@ enum StreamStatus { * @param o Original url * @param r Resolved url */ - public ByteRangeInputStream(URLOpener o, URLOpener r) { + public ByteRangeInputStream(URLOpener o, URLOpener r) throws IOException { this.originalURL = o; this.resolvedURL = r; + getInputStream(); } protected abstract URL getResolvedUrl(final HttpURLConnection connection 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/WebHdfsFileSystem.java index f836d4d052..bdf744a6d5 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 @@ -962,7 +962,8 @@ static URL removeOffsetParam(final URL url) throws MalformedURLException { } static class OffsetUrlInputStream extends ByteRangeInputStream { - OffsetUrlInputStream(OffsetUrlOpener o, OffsetUrlOpener r) { + OffsetUrlInputStream(OffsetUrlOpener o, OffsetUrlOpener r) + throws IOException { super(o, r); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java index 867886148f..09f025c65a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java @@ -182,9 +182,8 @@ public void testOpenNonExistFile() throws IOException { final Path p = new Path("/test/testOpenNonExistFile"); //open it as a file, should get FileNotFoundException try { - final FSDataInputStream in = fs.open(p); - in.read(); - fail(); + fs.open(p); + fail("Expected FileNotFoundException was not thrown"); } catch(FileNotFoundException fnfe) { WebHdfsFileSystem.LOG.info("This is expected.", fnfe); }