Exception should be raised even if count is 0

This commit is contained in:
Trustin Lee 2010-04-12 11:57:46 +00:00
parent 318a4d901f
commit 4e69cfe281

View File

@ -31,14 +31,14 @@ public class DefaultFileRegion implements FileRegion {
public long transferTo(WritableByteChannel target, long position) throws IOException {
long count = this.count - position;
if (count == 0) {
return 0L;
}
if (count < 0 || position < 0) {
throw new IllegalArgumentException(
"position out of range: " + position +
" (expected: 0 - " + (this.count - 1) + ")");
}
if (count == 0) {
return 0L;
}
return file.transferTo(this.position + position, count, target);
}