Skip to content

Commit 693e2d2

Browse files
committed
nit
1 parent 65e1b80 commit 693e2d2

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

netty-utils/src/main/java/org/asynchttpclient/netty/util/ByteBufUtils.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import io.netty.buffer.ByteBuf;
1717
import io.netty.buffer.Unpooled;
1818

19-
import java.nio.charset.CharacterCodingException;
2019
import java.nio.charset.Charset;
2120

2221
import static java.nio.charset.StandardCharsets.*;
@@ -49,11 +48,11 @@ public static String byteBuf2StringDefault(Charset charset, ByteBuf... bufs) {
4948
}
5049
}
5150

52-
public static String byteBuf2String(Charset charset, ByteBuf buf) throws CharacterCodingException {
51+
public static String byteBuf2String(Charset charset, ByteBuf buf) {
5352
return isUtf8OrUsAscii(charset) ? Utf8ByteBufCharsetDecoder.decodeUtf8(buf) : buf.toString(charset);
5453
}
5554

56-
public static String byteBuf2String(Charset charset, ByteBuf... bufs) throws CharacterCodingException {
55+
public static String byteBuf2String(Charset charset, ByteBuf... bufs) {
5756
return isUtf8OrUsAscii(charset) ? Utf8ByteBufCharsetDecoder.decodeUtf8(bufs) : byteBuf2StringDefault(charset, bufs);
5857
}
5958

netty-utils/src/main/java/org/asynchttpclient/netty/util/Utf8ByteBufCharsetDecoder.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class Utf8ByteBufCharsetDecoder {
2929
private static final int UTF_8_MAX_BYTES_PER_CHAR = 4;
3030
private static final char INVALID_CHAR_REPLACEMENT = '�';
3131

32-
private static final ThreadLocal<Utf8ByteBufCharsetDecoder> POOL = ThreadLocal.withInitial(() -> new Utf8ByteBufCharsetDecoder());
32+
private static final ThreadLocal<Utf8ByteBufCharsetDecoder> POOL = ThreadLocal.withInitial(Utf8ByteBufCharsetDecoder::new);
3333
private final CharsetDecoder decoder = configureReplaceCodingErrorActions(UTF_8.newDecoder());
3434
protected CharBuffer charBuffer = allocateCharBuffer(INITIAL_CHAR_BUFFER_SIZE);
3535
private ByteBuffer splitCharBuffer = ByteBuffer.allocate(UTF_8_MAX_BYTES_PER_CHAR);
@@ -161,14 +161,14 @@ protected void decodePartial(ByteBuffer nioBuffer, boolean endOfInput) {
161161
}
162162
}
163163

164-
private void decode(ByteBuffer[] nioBuffers, int length) {
164+
private void decode(ByteBuffer[] nioBuffers) {
165165
int count = nioBuffers.length;
166166
for (int i = 0; i < count; i++) {
167167
decodePartial(nioBuffers[i].duplicate(), i == count - 1);
168168
}
169169
}
170170

171-
private void decodeSingleNioBuffer(ByteBuffer nioBuffer, int length) {
171+
private void decodeSingleNioBuffer(ByteBuffer nioBuffer) {
172172
decoder.decode(nioBuffer, charBuffer, true);
173173
}
174174

@@ -181,9 +181,9 @@ public String decode(ByteBuf buf) {
181181
ensureCapacity(length);
182182

183183
if (buf.nioBufferCount() == 1) {
184-
decodeSingleNioBuffer(buf.internalNioBuffer(buf.readerIndex(), length).duplicate(), length);
184+
decodeSingleNioBuffer(buf.internalNioBuffer(buf.readerIndex(), length).duplicate());
185185
} else {
186-
decode(buf.nioBuffers(), buf.readableBytes());
186+
decode(buf.nioBuffers());
187187
}
188188

189189
return charBuffer.flip().toString();
@@ -219,7 +219,7 @@ public String decode(ByteBuf... bufs) {
219219
}
220220

221221
ensureCapacity(totalSize);
222-
decode(nioBuffers, totalSize);
222+
decode(nioBuffers);
223223

224224
return charBuffer.flip().toString();
225225
}

0 commit comments

Comments
 (0)