mirror of https://github.com/apache/lucene.git
LUCENE-3563: fix test bug
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1198341 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f8d7c081c8
commit
ed28039c43
|
@ -441,6 +441,7 @@ public final class PagedBytes {
|
|||
|
||||
@Override
|
||||
public void readBytes(byte[] b, int offset, int len) {
|
||||
assert b.length >= offset + len;
|
||||
final int offsetEnd = offset + len;
|
||||
while (true) {
|
||||
final int blockLeft = blockSize - currentBlockUpto;
|
||||
|
@ -485,6 +486,7 @@ public final class PagedBytes {
|
|||
|
||||
@Override
|
||||
public void writeBytes(byte[] b, int offset, int length) throws IOException {
|
||||
assert b.length >= offset + length;
|
||||
if (length == 0) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class TestPagedBytes extends LuceneTestCase {
|
|||
if (random.nextInt(10) == 7) {
|
||||
out.writeByte(answer[written++]);
|
||||
} else {
|
||||
int chunk = Math.max(random.nextInt(1000), numBytes - written);
|
||||
int chunk = Math.min(random.nextInt(1000), numBytes - written);
|
||||
out.writeBytes(answer, written, chunk);
|
||||
written += chunk;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class TestPagedBytes extends LuceneTestCase {
|
|||
if (random.nextInt(10) == 7) {
|
||||
verify[read++] = in.readByte();
|
||||
} else {
|
||||
int chunk = Math.max(random.nextInt(1000), numBytes - read);
|
||||
int chunk = Math.min(random.nextInt(1000), numBytes - read);
|
||||
in.readBytes(verify, read, chunk);
|
||||
read += chunk;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue