Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class HiveMQTTConnection implements MQTTConnection {
private static final Logger logger = Logger.getLogger(HiveMQTTConnection.class.getCanonicalName());

private static final Charset charset = Charset.forName("UTF-8");
private static final CharsetDecoder decoder = charset.newDecoder();
private static ThreadLocal<CharsetDecoder> decoder = ThreadLocal.withInitial(() -> charset.newDecoder());

private final Mqtt3BlockingClient client;
private final String clientId;
Expand Down Expand Up @@ -112,7 +112,7 @@ private void handlePublishReceived(Mqtt3Publish received) {

private String decode(ByteBuffer value) {
try {
return decoder.decode(value).toString();
return decoder.get().decode(value).toString();
} catch (CharacterCodingException e) {
throw new RuntimeException(new MQTTClientException("Failed to decode", e));
}
Expand Down