emqx / mqtt-jmeter

MQTT JMeter Plugin
https://www.emqx.com/en
Apache License 2.0
445 stars 194 forks source link

Resolve CharsetDecoder IllegalStateException when subscribe #126

Closed ChangingFond closed 2 years ago

ChangingFond commented 2 years ago

When I started 10000 threads to subsribe, console printed many logs like below.

I found CharsetDecode is not thread-safe, so it will throw IllegalStateException.

java.lang.IllegalStateException: Current state = RESET, new state = FLUSHED at java.nio.charset.CharsetDecoder.throwIllegalStateException(Unknown Source) ~[?:1.8.0_241] at java.nio.charset.CharsetDecoder.flush(Unknown Source) ~[?:1.8.0_241] at java.nio.charset.CharsetDecoder.decode(Unknown Source) ~[?:1.8.0_241] at net.xmeter.samplers.mqtt.hivemq.HiveMQTTConnection.decode(HiveMQTTConnection.java:115) ~[mqtt-xmeter-2.0.2-jar-with-dependencies.jar:?] at java.util.Optional.map(Unknown Source) ~[?:1.8.0_241] at net.xmeter.samplers.mqtt.hivemq.HiveMQTTConnection.handlePublishReceived(HiveMQTTConnection.java:109) ~[mqtt-xmeter-2.0.2-jar-with-dependencies.jar:?] at com.hivemq.client.internal.mqtt.mqtt3.Mqtt3AsyncClientView.lambda$callbackView$1(Mqtt3AsyncClientView.java:73) ~[mqtt-xmeter-2.0.2-jar-with-dependencies.jar:?] at com.hivemq.client.internal.mqtt.MqttAsyncClient$CallbackSubscriber.onNext(MqttAsyncClient.java:227) ~[mqtt-xmeter-2.0.2-jar-with-dependencies.jar:?] at com.hivemq.client.internal.mqtt.MqttAsyncClient$CallbackSubscriber.onNext(MqttAsyncClient.java:212) ~[mqtt-xmeter-2.0.2-jar-with-dependencies.jar:?] at com.hivemq.client.rx.FlowableWithSingle$SingleFutureSubscriber.onNext(FlowableWithSingle.java:377) ~[mqtt-xmeter-2.0.2-jar-with-dependencies.jar:?]