From: David ‘Bombe’ Roden Date: Sat, 12 Apr 2008 18:15:45 +0000 (+0000) Subject: do not access underlying input stream if remaining == 0 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=c42f215d227f1faf47595356e8d311182286707a;p=jSite2.git do not access underlying input stream if remaining == 0 git-svn-id: http://trooper/svn/projects/jSite/trunk@732 c3eda9e8-030b-0410-8277-bc7414b0a119 --- diff --git a/src/net/pterodactylus/util/io/LimitedInputStream.java b/src/net/pterodactylus/util/io/LimitedInputStream.java index 8e23f24..284d53d 100644 --- a/src/net/pterodactylus/util/io/LimitedInputStream.java +++ b/src/net/pterodactylus/util/io/LimitedInputStream.java @@ -38,6 +38,9 @@ public class LimitedInputStream extends FilterInputStream { */ @Override public synchronized int available() throws IOException { + if (remaining == 0) { + return 0; + } return (int) Math.min(super.available(), Math.min(Integer.MAX_VALUE, remaining)); } @@ -73,7 +76,7 @@ public class LimitedInputStream extends FilterInputStream { */ @Override public synchronized long skip(long n) throws IOException { - if (n < 0) { + if ((n < 0) || (remaining == 0)) { return 0; } long skipped = super.skip(Math.min(n, remaining));