EmptyByteBuf.getCharSequence(0,...) must return empty String (#9272)
Motivation: At the moment EmptyByteBuf.getCharSequence(0,...) will return null while it must return a "". Modifications: - Let EmptyByteBuf.getCharSequence(0,...) return "" - Add unit test Result: Fixes https://github.com/netty/netty/issues/9271.
This commit is contained in:
parent
36b2477c30
commit
eae9492c40
@ -661,7 +661,7 @@ public final class EmptyByteBuf extends ByteBuf {
|
|||||||
@Override
|
@Override
|
||||||
public CharSequence readCharSequence(int length, Charset charset) {
|
public CharSequence readCharSequence(int length, Charset charset) {
|
||||||
checkLength(length);
|
checkLength(length);
|
||||||
return null;
|
return StringUtil.EMPTY_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/package io.netty.buffer;
|
*/package io.netty.buffer;
|
||||||
|
|
||||||
|
import io.netty.util.CharsetUtil;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.*;
|
||||||
@ -93,4 +94,11 @@ public class EmptyByteBufTest {
|
|||||||
assertTrue(emptyAbstract.release());
|
assertTrue(emptyAbstract.release());
|
||||||
assertFalse(empty.release());
|
assertFalse(empty.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetCharSequence() {
|
||||||
|
EmptyByteBuf empty = new EmptyByteBuf(UnpooledByteBufAllocator.DEFAULT);
|
||||||
|
assertEquals("", empty.readCharSequence(0, CharsetUtil.US_ASCII));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user