Exception should be raised even if count is 0
This commit is contained in:
parent
318a4d901f
commit
4e69cfe281
@ -31,14 +31,14 @@ public class DefaultFileRegion implements FileRegion {
|
|||||||
|
|
||||||
public long transferTo(WritableByteChannel target, long position) throws IOException {
|
public long transferTo(WritableByteChannel target, long position) throws IOException {
|
||||||
long count = this.count - position;
|
long count = this.count - position;
|
||||||
if (count == 0) {
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
if (count < 0 || position < 0) {
|
if (count < 0 || position < 0) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"position out of range: " + position +
|
"position out of range: " + position +
|
||||||
" (expected: 0 - " + (this.count - 1) + ")");
|
" (expected: 0 - " + (this.count - 1) + ")");
|
||||||
}
|
}
|
||||||
|
if (count == 0) {
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
return file.transferTo(this.position + position, count, target);
|
return file.transferTo(this.position + position, count, target);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user