Fixed issue: NETTY-176 toByteBuffer() and slice() sometimes do not respect byte order
* Added tests to make sure all ChannelBuffer implementations are fixed * Fixed the byte order problem in HeapChannelBuffer
This commit is contained in:
parent
b9cd9de5ed
commit
70e90fc85e
@ -198,7 +198,7 @@ public abstract class HeapChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
|
||||
public ByteBuffer toByteBuffer(int index, int length) {
|
||||
return ByteBuffer.wrap(array, index, length);
|
||||
return ByteBuffer.wrap(array, index, length).order(order());
|
||||
}
|
||||
|
||||
public String toString(int index, int length, String charsetName) {
|
||||
|
@ -1443,6 +1443,11 @@ public abstract class AbstractChannelBufferTest {
|
||||
assertTrue(buffer.getByte(1) == duplicate.getByte(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSlice() throws Exception {
|
||||
assertEquals(buffer.order(), buffer.slice(1, buffer.capacity() - 1).order());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
assertFalse(buffer.equals(null));
|
||||
@ -1561,6 +1566,11 @@ public abstract class AbstractChannelBufferTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToByteBuffer3() {
|
||||
assertEquals(buffer.order(), buffer.toByteBuffer().order());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToByteBuffers1() {
|
||||
byte[] value = new byte[buffer.capacity()];
|
||||
|
Loading…
Reference in New Issue
Block a user