@Test public void testToStringDoesNotThrowIndexOutOfBounds() { CompositeByteBuf buffer = Unpooled.compositeBuffer(); try { byte[] bytes = "1234".getBytes(CharsetUtil.UTF_8); buffer.addComponent(Unpooled.buffer(bytes.length).writeBytes(bytes)); buffer.addComponent(Unpooled.buffer(bytes.length).writeBytes(bytes)); assertEquals("1234", buffer.toString(bytes.length, bytes.length, CharsetUtil.UTF_8)); } finally { buffer.release(); } }
public static byte[] getBytes(ByteBuf buf) { return getBytes(buf, buf.readerIndex(), buf.readableBytes()); }
ByteBufUtil { public static byte[] getBytes(ByteBuf buf) { return getBytes(buf, buf.readerIndex(), buf.readableBytes()); } }
ByteBufUtil { public static byte[] getBytes(ByteBuf buf) { return getBytes(buf, buf.readerIndex(), buf.readableBytes()); } private  ByteBufUtil(); }
ByteBufUtil { public static byte[] getBytes(ByteBuf buf) { return getBytes(buf, buf.readerIndex(), buf.readableBytes()); } private  ByteBufUtil(); static String hexDump(ByteBuf buffer); static String hexDump(ByteBuf buffer, int fromIndex, int length); static String hexDump(byte[] array); static String hexDump(byte[] array, int fromIndex, int length); static byte decodeHexByte(CharSequence s, int pos); static byte[] decodeHexDump(CharSequence hexDump); static byte[] decodeHexDump(CharSequence hexDump, int fromIndex, int length); static boolean ensureWritableSuccess(int ensureWritableResult); static int hashCode(ByteBuf buffer); static int indexOf(ByteBuf needle, ByteBuf haystack); static boolean equals(ByteBuf a, int aStartIndex, ByteBuf b, int bStartIndex, int length); static boolean equals(ByteBuf bufferA, ByteBuf bufferB); static int compare(ByteBuf bufferA, ByteBuf bufferB); static int indexOf(ByteBuf buffer, int fromIndex, int toIndex, byte value); static short swapShort(short value); static int swapMedium(int value); static int swapInt(int value); static long swapLong(long value); @SuppressWarnings("deprecation") static ByteBuf writeShortBE(ByteBuf buf, int shortValue); @SuppressWarnings("deprecation") static ByteBuf setShortBE(ByteBuf buf, int index, int shortValue); @SuppressWarnings("deprecation") static ByteBuf writeMediumBE(ByteBuf buf, int mediumValue); static ByteBuf readBytes(ByteBufAllocator alloc, ByteBuf buffer, int length); static ByteBuf writeUtf8(ByteBufAllocator alloc, CharSequence seq); static int writeUtf8(ByteBuf buf, CharSequence seq); static int reserveAndWriteUtf8(ByteBuf buf, CharSequence seq, int reserveBytes); static int utf8MaxBytes(final int seqLength); static int utf8MaxBytes(CharSequence seq); static int utf8Bytes(final CharSequence seq); static ByteBuf writeAscii(ByteBufAllocator alloc, CharSequence seq); static int writeAscii(ByteBuf buf, CharSequence seq); static ByteBuf encodeString(ByteBufAllocator alloc, CharBuffer src, Charset charset); static ByteBuf encodeString(ByteBufAllocator alloc, CharBuffer src, Charset charset, int extraCapacity); static ByteBuf threadLocalDirectBuffer(); static byte[] getBytes(ByteBuf buf); static byte[] getBytes(ByteBuf buf, int start, int length); static byte[] getBytes(ByteBuf buf, int start, int length, boolean copy); static void copy(AsciiString src, ByteBuf dst); static void copy(AsciiString src, int srcIdx, ByteBuf dst, int dstIdx, int length); static void copy(AsciiString src, int srcIdx, ByteBuf dst, int length); static String prettyHexDump(ByteBuf buffer); static String prettyHexDump(ByteBuf buffer, int offset, int length); static void appendPrettyHexDump(StringBuilder dump, ByteBuf buf); static void appendPrettyHexDump(StringBuilder dump, ByteBuf buf, int offset, int length); static boolean isText(ByteBuf buf, Charset charset); static boolean isText(ByteBuf buf, int index, int length, Charset charset); }
ByteBufUtil { public static byte[] getBytes(ByteBuf buf) { return getBytes(buf, buf.readerIndex(), buf.readableBytes()); } private  ByteBufUtil(); static String hexDump(ByteBuf buffer); static String hexDump(ByteBuf buffer, int fromIndex, int length); static String hexDump(byte[] array); static String hexDump(byte[] array, int fromIndex, int length); static byte decodeHexByte(CharSequence s, int pos); static byte[] decodeHexDump(CharSequence hexDump); static byte[] decodeHexDump(CharSequence hexDump, int fromIndex, int length); static boolean ensureWritableSuccess(int ensureWritableResult); static int hashCode(ByteBuf buffer); static int indexOf(ByteBuf needle, ByteBuf haystack); static boolean equals(ByteBuf a, int aStartIndex, ByteBuf b, int bStartIndex, int length); static boolean equals(ByteBuf bufferA, ByteBuf bufferB); static int compare(ByteBuf bufferA, ByteBuf bufferB); static int indexOf(ByteBuf buffer, int fromIndex, int toIndex, byte value); static short swapShort(short value); static int swapMedium(int value); static int swapInt(int value); static long swapLong(long value); @SuppressWarnings("deprecation") static ByteBuf writeShortBE(ByteBuf buf, int shortValue); @SuppressWarnings("deprecation") static ByteBuf setShortBE(ByteBuf buf, int index, int shortValue); @SuppressWarnings("deprecation") static ByteBuf writeMediumBE(ByteBuf buf, int mediumValue); static ByteBuf readBytes(ByteBufAllocator alloc, ByteBuf buffer, int length); static ByteBuf writeUtf8(ByteBufAllocator alloc, CharSequence seq); static int writeUtf8(ByteBuf buf, CharSequence seq); static int reserveAndWriteUtf8(ByteBuf buf, CharSequence seq, int reserveBytes); static int utf8MaxBytes(final int seqLength); static int utf8MaxBytes(CharSequence seq); static int utf8Bytes(final CharSequence seq); static ByteBuf writeAscii(ByteBufAllocator alloc, CharSequence seq); static int writeAscii(ByteBuf buf, CharSequence seq); static ByteBuf encodeString(ByteBufAllocator alloc, CharBuffer src, Charset charset); static ByteBuf encodeString(ByteBufAllocator alloc, CharBuffer src, Charset charset, int extraCapacity); static ByteBuf threadLocalDirectBuffer(); static byte[] getBytes(ByteBuf buf); static byte[] getBytes(ByteBuf buf, int start, int length); static byte[] getBytes(ByteBuf buf, int start, int length, boolean copy); static void copy(AsciiString src, ByteBuf dst); static void copy(AsciiString src, int srcIdx, ByteBuf dst, int dstIdx, int length); static void copy(AsciiString src, int srcIdx, ByteBuf dst, int length); static String prettyHexDump(ByteBuf buffer); static String prettyHexDump(ByteBuf buffer, int offset, int length); static void appendPrettyHexDump(StringBuilder dump, ByteBuf buf); static void appendPrettyHexDump(StringBuilder dump, ByteBuf buf, int offset, int length); static boolean isText(ByteBuf buf, Charset charset); static boolean isText(ByteBuf buf, int index, int length, Charset charset);  }