Fixed a problem where ReplayingDecoderBuffer.readBytes/readSlice() and AbstractChannelBuffer.readSlice() doesn't work properly.
This commit is contained in:
parent
549145687e
commit
414e02cb3e
@ -267,6 +267,7 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
if (length == 0) {
|
||||
return ChannelBuffers.EMPTY_BUFFER;
|
||||
}
|
||||
// TODO: Allow a user to specify the buffer factory as an overloaded method.
|
||||
ChannelBuffer buf = ChannelBuffers.buffer(order(), length);
|
||||
buf.writeBytes(this, readerIndex, length);
|
||||
readerIndex += length;
|
||||
@ -278,7 +279,7 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
if (endIndex < 0) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
return readBytes(endIndex);
|
||||
return readBytes(endIndex - readerIndex);
|
||||
}
|
||||
|
||||
public ChannelBuffer readSlice(int length) {
|
||||
@ -292,7 +293,7 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
if (endIndex < 0) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
return readSlice(endIndex);
|
||||
return readSlice(endIndex - readerIndex);
|
||||
}
|
||||
|
||||
public void readBytes(byte[] dst, int dstIndex, int length) {
|
||||
|
@ -57,7 +57,7 @@ class ReplayingDecoderBuffer implements ChannelBuffer {
|
||||
public void clear() {
|
||||
reject();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return this == obj;
|
||||
@ -255,7 +255,7 @@ class ReplayingDecoderBuffer implements ChannelBuffer {
|
||||
if (endIndex < 0) {
|
||||
throw REPLAY;
|
||||
}
|
||||
return readBytes(endIndex);
|
||||
return buffer.readBytes(endIndex - buffer.readerIndex());
|
||||
}
|
||||
|
||||
public int readBytes(GatheringByteChannel out, int length)
|
||||
@ -275,7 +275,7 @@ class ReplayingDecoderBuffer implements ChannelBuffer {
|
||||
if (endIndex < 0) {
|
||||
throw REPLAY;
|
||||
}
|
||||
return readSlice(endIndex);
|
||||
return buffer.readSlice(endIndex - buffer.readerIndex());
|
||||
}
|
||||
|
||||
public ChannelBuffer readSlice(int length) {
|
||||
|
Loading…
Reference in New Issue
Block a user