Author: norman
Date: Mon Apr 11 20:05:41 2011
New Revision: 1091189

URL: http://svn.apache.org/viewvc?rev=1091189&view=rev
Log:
PartialFetchBodyElement.LimitingInputStream#available does not calculate the 
value in a correct way. See IMAP-295

Modified:
    
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/PartialFetchBodyElement.java

Modified: 
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/PartialFetchBodyElement.java
URL: 
http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/PartialFetchBodyElement.java?rev=1091189&r1=1091188&r2=1091189&view=diff
==============================================================================
--- 
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/PartialFetchBodyElement.java
 (original)
+++ 
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/PartialFetchBodyElement.java
 Mon Apr 11 20:05:41 2011
@@ -166,11 +166,19 @@ final class PartialFetchBodyElement impl
          * @see java.io.FilterInputStream#available()
          */
         public int available() throws IOException {
-            int a = in.available() - (int)offset - (int) length;
-            if (a < -1) {
-                throw new IOException("Unable to calculate size");
+            // Correctly calculate in available bytes
+            // See IMAP-295
+            checkOffset();
+            int i = in.available();
+            if (i == -1) {
+                return -1;
+            } else {
+                if (i >= length) {
+                    return (int) length - (int) pos;
+                } else {
+                    return i;
+                }
             }
-            return a;
         }
 
         public void mark(int readlimit) {



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to