Uploaded image for project: 'AMQ Broker'
  1. AMQ Broker
  2. ENTMQBR-3614

MQTT connection failure handling may lead to NPE

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • None
    • None

      https://issues.apache.org/jira/browse/ARTEMIS-2782

      Our (EnMasse) automated test suite includes some MQTT use-cases that rely on Artemis's native MQTT support. A recent test run failed as follows:

      2020-05-26T05:04:21.293Z INFO [message] AMQ601500: User test is sending a core message on target resource: ServerSessionImpl() [with parameters: [null, org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage@50b01c3e, true, false, RoutingContextImpl(Address=jmsTopicDurSubs, routingType=MULTICAST, PreviousAddress=jmsTopicDurSubs previousRoute:MULTICAST, reusable=true, version=2147470526)2020-05-26T05:04:21.293Z INFO [message] AMQ601500: User test is sending a core message on target resource: ServerSessionImpl() [with parameters: [null, org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage@50b01c3e, true, false, RoutingContextImpl(Address=jmsTopicDurSubs, routingType=MULTICAST, PreviousAddress=jmsTopicDurSubs previousRoute:MULTICAST, reusable=true, version=2147470526)..................................................***** durable queues jmsTopicDurSubs: queueID=279451 address:jmsTopicDurSubs name:jmsCliId.sub1DurSub filter:null queueID=279456 address:jmsTopicDurSubs name:jmsCliId.sub2DurSub filter:null***** non durable for jmsTopicDurSubs:Exception in thread "Thread-10" java.lang.NullPointerException at org.apache.activemq.artemis.core.protocol.mqtt.MQTTConnectionManager.disconnect(MQTTConnectionManager.java:146) at org.apache.activemq.artemis.core.protocol.mqtt.MQTTFailureListener.connectionFailed(MQTTFailureListener.java:37) at org.apache.activemq.artemis.core.protocol.mqtt.MQTTConnection.fail(MQTTConnection.java:149) at org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl.issueFailure(RemotingServiceImpl.java:572) at org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl.connectionException(RemotingServiceImpl.java:578) at org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor$Listener$1.run(NettyAcceptor.java:920)

      I don't understand the root cause that caused the MQTT connection to be closed, but the stack trace highlights a problem in the error handlng in MQTTConnectionManager.disconnect. If the session.getSessionState() returns null, as synchronising on a null is disallowed, the method will end with a NPE exception.

            rhn-support-jbertram Justin Bertram
            keithbwall Keith Wall
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: