hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r1301287 - in /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs: ./ src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/ src/test/java/org/apache/hadoop/hdfs/web/
Date Fri, 16 Mar 2012 00:01:23 GMT
Author: szetszwo
Date: Fri Mar 16 00:01:23 2012
New Revision: 1301287

URL: http://svn.apache.org/viewvc?rev=1301287&view=rev
Log:
HDFS-3101. Cannot read empty file using WebHDFS.

Modified:
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1301287&r1=1301286&r2=1301287&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Fri Mar 16 00:01:23 2012
@@ -701,6 +701,8 @@ Release 0.23.2 - UNRELEASED 
     HDFS-2038. Update TestHDFSCLI to handle relative paths with globs.
     (Kihwal Lee via szetszwo)
 
+    HDFS-3101. Cannot read empty file using WebHDFS.  (szetszwo)
+
 Release 0.23.1 - 2012-02-17 
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java?rev=1301287&r1=1301286&r2=1301287&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
(original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
Fri Mar 16 00:01:23 2012
@@ -146,9 +146,11 @@ public class NamenodeWebHdfsMethods {
         throw new FileNotFoundException("File " + path + " not found.");
       }
       final long len = status.getLen();
-      if (op == GetOpParam.Op.OPEN && (openOffset < 0L || openOffset >= len))
{
-        throw new IOException("Offset=" + openOffset + " out of the range [0, "
-          + len + "); " + op + ", path=" + path);
+      if (op == GetOpParam.Op.OPEN) {
+        if (openOffset < 0L || (openOffset >= len && len > 0)) {
+          throw new IOException("Offset=" + openOffset
+              + " out of the range [0, " + len + "); " + op + ", path=" + path);
+        }
       }
 
       if (len > 0) {

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java?rev=1301287&r1=1301286&r2=1301287&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java
(original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java
Fri Mar 16 00:01:23 2012
@@ -176,7 +176,21 @@ public class TestWebHdfsFileSystemContra
   }
 
   public void testSeek() throws IOException {
-    final Path p = new Path("/test/testSeek");
+    final Path dir = new Path("/test/testSeek");
+    assertTrue(fs.mkdirs(dir));
+
+    { //test zero file size
+      final Path zero = new Path(dir, "zero");
+      fs.create(zero).close();
+      
+      int count = 0;
+      final FSDataInputStream in = fs.open(zero);
+      for(; in.read() != -1; count++);
+      in.close();
+      assertEquals(0, count);
+    }
+
+    final Path p = new Path(dir, "file");
     createFile(p);
 
     final int one_third = data.length/3;
@@ -248,7 +262,6 @@ public class TestWebHdfsFileSystemContra
       final FSDataInputStream in = fs.open(root);
       in.read();
       fail();
-      fail();
     } catch(IOException e) {
       WebHdfsFileSystem.LOG.info("This is expected.", e);
     }



Mime
View raw message