projects
/
jSite2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
move project-related classes to own project
[jSite2.git]
/
src
/
net
/
pterodactylus
/
util
/
io
/
LimitedInputStream.java
diff --git
a/src/net/pterodactylus/util/io/LimitedInputStream.java
b/src/net/pterodactylus/util/io/LimitedInputStream.java
index
8e23f24
..
284d53d
100644
(file)
--- 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 {
*/
@Override
public synchronized int available() throws IOException {
+ if (remaining == 0) {
+ return 0;
+ }
return (int) Math.min(super.available(), Math.min(Integer.MAX_VALUE, remaining));
}
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 {
*/
@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));
return 0;
}
long skipped = super.skip(Math.min(n, remaining));