Ver código fonte

commit c239ea635813b37d096cb8446c5c7dc55c62afb5
Author: Hong Tang <htang@yahoo-inc.com>
Date: Fri Sep 3 01:00:17 2010 -0700

MAPREDUCE-2023. TestDFSIO read test may not read specified bytes. From https://issues.apache.org/jira/secure/attachment/12453758/mr-2023-yahoo-hadoop-20.1xx.patch. (htang)

+++ b/YAHOO-CHANGES.txt
+ MAPREDUCE-2023. TestDFSIO read test may not read specified bytes. (htang)
+


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-patches@1077663 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 14 anos atrás
pai
commit
efaecf7d0a
1 arquivos alterados com 5 adições e 4 exclusões
  1. 5 4
      src/test/org/apache/hadoop/fs/TestDFSIO.java

+ 5 - 4
src/test/org/apache/hadoop/fs/TestDFSIO.java

@@ -272,10 +272,11 @@ public class TestDFSIO extends Configured implements Tool {
       totalSize *= MEGA;
       // open file
       DataInputStream in = fs.open(new Path(DATA_DIR, name));
+      long actualSize = 0;
       try {
-        long actualSize = 0;
-        for(int curSize = bufferSize; curSize == bufferSize;) {
-          curSize = in.read(buffer, 0, bufferSize);
+        while (actualSize < totalSize) {
+          int curSize = in.read(buffer, 0, bufferSize);
+          if (curSize < 0) break;
           actualSize += curSize;
           reporter.setStatus("reading " + name + "@" + 
                              actualSize + "/" + totalSize 
@@ -284,7 +285,7 @@ public class TestDFSIO extends Configured implements Tool {
       } finally {
         in.close();
       }
-      return Long.valueOf(totalSize);
+      return Long.valueOf(actualSize);
     }
   }