Fixed issue: NETTY-176 ByteBufferBackedBuffer.toByteBuffer() and slice() do not respect byte order

This commit is contained in:
Trustin Lee 2009-06-17 07:57:14 +00:00
parent e04d8e9de1
commit b9cd9de5ed

View File

@ -285,9 +285,10 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
public ByteBuffer toByteBuffer(int index, int length) { public ByteBuffer toByteBuffer(int index, int length) {
if (index == 0 && length == capacity()) { if (index == 0 && length == capacity()) {
return buffer.duplicate(); return buffer.duplicate().order(order());
} else { } else {
return ((ByteBuffer) buffer.duplicate().position(index).limit(index + length)).slice(); return ((ByteBuffer) buffer.duplicate().position(
index).limit(index + length)).slice().order(order());
} }
} }
@ -319,7 +320,8 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
return ChannelBuffers.EMPTY_BUFFER; return ChannelBuffers.EMPTY_BUFFER;
} }
return new ByteBufferBackedChannelBuffer( return new ByteBufferBackedChannelBuffer(
((ByteBuffer) buffer.duplicate().position(index).limit(index + length))); ((ByteBuffer) buffer.duplicate().position(
index).limit(index + length)).order(order()));
} }
} }