[jboss-svn-commits] JBoss Common SVN: r3262 - jzipfile/trunk/src/main/java/org/jboss/jzipfile.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jun 16 10:24:45 EDT 2009
Author: david.lloyd at jboss.com
Date: 2009-06-16 10:24:45 -0400 (Tue, 16 Jun 2009)
New Revision: 3262
Modified:
jzipfile/trunk/src/main/java/org/jboss/jzipfile/LimitedInputStream.java
Log:
Tolerate abrupt EOF on nested streams
Modified: jzipfile/trunk/src/main/java/org/jboss/jzipfile/LimitedInputStream.java
===================================================================
--- jzipfile/trunk/src/main/java/org/jboss/jzipfile/LimitedInputStream.java 2009-06-16 13:57:28 UTC (rev 3261)
+++ jzipfile/trunk/src/main/java/org/jboss/jzipfile/LimitedInputStream.java 2009-06-16 14:24:45 UTC (rev 3262)
@@ -24,6 +24,7 @@
import java.io.InputStream;
import java.io.IOException;
+import java.io.EOFException;
import static java.lang.StrictMath.min;
class LimitedInputStream extends InputStream {
@@ -37,12 +38,15 @@
}
public int read() throws IOException {
- if (limit > 0) {
+ if (limit > 0) try {
final int b = delegate.read();
if (b == -1) {
limit = 0;
}
return b;
+ } catch (EOFException ex) {
+ limit = 0;
+ // fall out
}
return -1;
}
@@ -55,7 +59,13 @@
if (limit == 0) {
return -1;
}
- final int cnt = delegate.read(b, off, (int)min(limit, len));
+ final int cnt;
+ try {
+ cnt = delegate.read(b, off, (int)min(limit, len));
+ } catch (EOFException ex) {
+ limit = 0;
+ return -1;
+ }
if (cnt > 0) {
limit -= (long)cnt;
} else {
More information about the jboss-svn-commits
mailing list