Author: szetszwo
Date: Wed Oct 28 23:30:44 2009
New Revision: 830794

URL: http://svn.apache.org/viewvc?rev=830794&view=rev
Log:
HDFS-691. Fix an overflow error in DFSClient.DFSInputStream.available().

Modified:
    hadoop/hdfs/branches/branch-0.21/CHANGES.txt
    
hadoop/hdfs/branches/branch-0.21/src/java/org/apache/hadoop/hdfs/DFSClient.java

Modified: hadoop/hdfs/branches/branch-0.21/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/hdfs/branches/branch-0.21/CHANGES.txt?rev=830794&r1=830793&r2=830794&view=diff
==============================================================================
--- hadoop/hdfs/branches/branch-0.21/CHANGES.txt (original)
+++ hadoop/hdfs/branches/branch-0.21/CHANGES.txt Wed Oct 28 23:30:44 2009
@@ -433,6 +433,9 @@
 
     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

Modified: 
hadoop/hdfs/branches/branch-0.21/src/java/org/apache/hadoop/hdfs/DFSClient.java
URL: 
http://svn.apache.org/viewvc/hadoop/hdfs/branches/branch-0.21/src/java/org/apache/hadoop/hdfs/DFSClient.java?rev=830794&r1=830793&r2=830794&view=diff
==============================================================================
--- 
hadoop/hdfs/branches/branch-0.21/src/java/org/apache/hadoop/hdfs/DFSClient.java 
(original)
+++ 
hadoop/hdfs/branches/branch-0.21/src/java/org/apache/hadoop/hdfs/DFSClient.java 
Wed Oct 28 23:30:44 2009
@@ -2313,14 +2313,18 @@
       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;
     }
 
     /**


Reply via email to