mirror of https://github.com/apache/activemq.git
[AMQ-6831, AMQ-6771] trigger eofexception on read -1 - AMQ6522Test
This commit is contained in:
parent
ada50f74f9
commit
e793260573
|
@ -75,7 +75,11 @@ public class ByteSequence {
|
|||
|
||||
public void reset() {
|
||||
length = remaining();
|
||||
if (length > 0) {
|
||||
System.arraycopy(data, offset, data, 0, length);
|
||||
} else {
|
||||
length = 0;
|
||||
}
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -627,7 +627,13 @@ public class Journal {
|
|||
private void ensureAvailable(ByteSequence bs, RandomAccessFile reader, int required) throws IOException {
|
||||
if (bs.remaining() < required) {
|
||||
bs.reset();
|
||||
bs.setLength(bs.length + reader.read(bs.data, bs.length, bs.data.length - bs.length));
|
||||
int read = reader.read(bs.data, bs.length, bs.data.length - bs.length);
|
||||
if (read < 0) {
|
||||
if (bs.remaining() == 0) {
|
||||
throw new EOFException("request for " + required + " bytes reached EOF");
|
||||
}
|
||||
}
|
||||
bs.setLength(bs.length + read);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue