Skip to content

Commit 65e5f38

Browse files
committed
Directly use Utf8ByteBufCharsetDecoder for decoding WebSocket frames
1 parent d103236 commit 65e5f38

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

client/src/main/java/org/asynchttpclient/netty/ws/NettyWebSocket.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
package org.asynchttpclient.netty.ws;
1515

1616
import static io.netty.buffer.Unpooled.wrappedBuffer;
17-
import static java.nio.charset.StandardCharsets.UTF_8;
1817
import static org.asynchttpclient.netty.util.ByteBufUtils.byteBuf2Bytes;
1918
import io.netty.channel.Channel;
2019
import io.netty.channel.ChannelPromise;
@@ -30,7 +29,7 @@
3029
import java.util.Collection;
3130
import java.util.concurrent.ConcurrentLinkedQueue;
3231

33-
import org.asynchttpclient.netty.util.ByteBufUtils;
32+
import org.asynchttpclient.netty.util.Utf8ByteBufCharsetDecoder;
3433
import org.asynchttpclient.ws.WebSocket;
3534
import org.asynchttpclient.ws.WebSocketByteListener;
3635
import org.asynchttpclient.ws.WebSocketCloseCodeReasonListener;
@@ -279,9 +278,9 @@ public void onBinaryFrame(BinaryWebSocketFrame frame) {
279278
public void onTextFrame(TextWebSocketFrame frame) {
280279
if (interestedInTextMessages) {
281280
try {
282-
notifyTextListeners(ByteBufUtils.byteBuf2String(UTF_8, frame.content()));
281+
notifyTextListeners(Utf8ByteBufCharsetDecoder.decodeUtf8(frame.content()));
283282
} catch (CharacterCodingException e) {
284-
throw new IllegalStateException(e);
283+
throw new IllegalArgumentException(e);
285284
}
286285
}
287286
}

0 commit comments

Comments
 (0)