SwappedByteBuf.unwrap() should return wrapped buffer.
Motivation: SwappedByteBuf.unwrap() not returned the wrapped buffer but the buffer that was wrapped by the original buffer. This is not correct. Modifications: Correctly return wrapped buffer and fix test. Result: SwappedByteBuf.unwrap() works as expected.
This commit is contained in:
parent
6dbec4181c
commit
feae0435b5
@ -69,7 +69,7 @@ public class SwappedByteBuf extends ByteBuf {
|
||||
|
||||
@Override
|
||||
public ByteBuf unwrap() {
|
||||
return buf.unwrap();
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,6 +22,7 @@ import java.nio.ByteOrder;
|
||||
import java.util.Random;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.sameInstance;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
@ -156,7 +157,7 @@ public class ByteBufDerivationTest {
|
||||
ByteBuf swapped = buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
assertThat(swapped, instanceOf(SwappedByteBuf.class));
|
||||
assertThat(swapped.unwrap(), is((ByteBuf) null));
|
||||
assertThat(swapped.unwrap(), sameInstance(buf));
|
||||
assertThat(swapped.order(ByteOrder.LITTLE_ENDIAN), sameInstance(swapped));
|
||||
assertThat(swapped.order(ByteOrder.BIG_ENDIAN), sameInstance(buf));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user