commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1302652 - /commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java
Date Mon, 19 Mar 2012 20:56:35 GMT
Author: ggregory
Date: Mon Mar 19 20:56:34 2012
New Revision: 1302652

URL: http://svn.apache.org/viewvc?rev=1302652&view=rev
Log:
[CODEC-130] Base64InputStream.skip skips underlying stream, not output. Can skip more than
Integer.MAX_VALUE at a time.

Modified:
    commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java

Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java?rev=1302652&r1=1302651&r2=1302652&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java
(original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java
Mon Mar 19 20:56:34 2012
@@ -163,21 +163,17 @@ public class BaseNCodecInputStream exten
 
         // skip in chunks of 512 bytes
         final byte[] b = new byte[512];
-        final int max = (int) Math.min(n, Integer.MAX_VALUE);
-        int total = 0;
+        long todo = n;
 
-        while (total < max) {
-            int len = max - total;
-            if (len > b.length) {
-                len = b.length;
-            }
-            len = read(b, 0, len);
+        while (todo > 0) {
+            int len = (int) Math.min(b.length, todo);
+            len = this.read(b, 0, len);
             if (len == EOF) {
                 break;
             }
-            total += len;
+            todo -= len;
         }
 
-        return total;
+        return n - todo;
     }
 }



Mime
View raw message