瀏覽代碼

HDFS-691. Fix an overflow error in DFSClient.DFSInputStream.available().

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/trunk@830793 13f79535-47bb-0310-9956-ffa450edef68
Tsz-wo Sze 15 年之前
父節點
當前提交
43774de11c
共有 2 個文件被更改,包括 11 次插入4 次删除
  1. 5 2
      CHANGES.txt
  2. 6 2
      src/java/org/apache/hadoop/hdfs/DFSClient.java

+ 5 - 2
CHANGES.txt

@@ -31,8 +31,6 @@ Trunk (unreleased changes)
     HDFS-726. Eclipse .classpath template has outdated jar files and is
     missing some new ones. (cos)
 
-    HDFS-735. TestReadWhileWriting has wrong line termination symbols (cos)
-
 Release 0.21.0 - Unreleased
 
   INCOMPATIBLE CHANGES
@@ -462,6 +460,11 @@ Release 0.21.0 - Unreleased
 
     HDFS-625. Fix NullPointerException thrown from ListPathServlet. (suresh)
 
+    HDFS-735. TestReadWhileWriting has wrong line termination symbols (cos)
+
+    HDFS-691. Fix an overflow error in DFSClient.DFSInputStream.available().
+    (szetszwo)
+
 Release 0.20.2 - Unreleased
 
   IMPROVEMENTS

+ 6 - 2
src/java/org/apache/hadoop/hdfs/DFSClient.java

@@ -2331,14 +2331,18 @@ public class DFSClient implements FSConstants, java.io.Closeable {
       return pos;
     }
 
-    /**
+    /** Return the size of the remaining available bytes
+     * if the size is less than or equal to {@link Integer#MAX_VALUE},
+     * otherwise, return {@link Integer#MAX_VALUE}.
      */
     @Override
     public synchronized int available() throws IOException {
       if (closed) {
         throw new IOException("Stream closed");
       }
-      return (int) (getFileLength() - pos);
+
+      final long remaining = getFileLength() - pos;
+      return remaining <= Integer.MAX_VALUE? (int)remaining: Integer.MAX_VALUE;
     }
 
     /**