mirror of https://github.com/apache/activemq.git
[AMQ-6831, AMQ-6771] trigger eofexception on read -1 - AMQ6522Test
(cherry picked from commit e793260573
)
This commit is contained in:
parent
b19ed4815b
commit
d66e96e8bc
|
@ -75,7 +75,11 @@ public class ByteSequence {
|
|||
|
||||
public void reset() {
|
||||
length = remaining();
|
||||
System.arraycopy(data, offset, data, 0, length);
|
||||
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