comparison src/org/tmatesoft/hg/internal/FilterDataAccess.java @ 188:facfd8518367

[4] IllegalArgumentException: Underflow. Legitimate attempt to read 0 bytes lead to exception
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 14 Apr 2011 02:46:35 +0200
parents b413b16d10a5
children 5e95b0da26f2
comparison
equal deleted inserted replaced
187:b8534ac8ac67 188:facfd8518367
97 return dataAccess.readByte(); 97 return dataAccess.readByte();
98 } 98 }
99 99
100 @Override 100 @Override
101 public void readBytes(byte[] b, int off, int len) throws IOException { 101 public void readBytes(byte[] b, int off, int len) throws IOException {
102 if (len == 0) {
103 return;
104 }
102 if (count <= 0 || len > count) { 105 if (count <= 0 || len > count) {
103 throw new IllegalArgumentException("Underflow"); // XXX be descriptive 106 throw new IllegalArgumentException(String.format("Underflow. Bytes left: %d, asked to read %d", count, len));
104 } 107 }
105 if (count == length) { 108 if (count == length) {
106 dataAccess.seek(offset); 109 dataAccess.seek(offset);
107 } 110 }
108 dataAccess.readBytes(b, off, len); 111 dataAccess.readBytes(b, off, len);