From c42f215d227f1faf47595356e8d311182286707a Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 12 Apr 2008 18:15:45 +0000 Subject: [PATCH] do not access underlying input stream if remaining == 0 git-svn-id: http://trooper/svn/projects/jSite/trunk@732 c3eda9e8-030b-0410-8277-bc7414b0a119 --- src/net/pterodactylus/util/io/LimitedInputStream.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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)); -- 2.7.4