[ 
https://issues.apache.org/jira/browse/ARTEMIS-2782?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17117895#comment-17117895
 ] 

Justin Bertram commented on ARTEMIS-2782:
-----------------------------------------

Looking at the code I don't yet see how it's possible for 
{{org.apache.activemq.artemis.core.protocol.mqtt.MQTTSession#getSessionState}} 
to return {{null}} because the {{state}} is initialized when the 
{{MQTTSession}} is instantiated and it never set to {{null}} after that.

Is this something you're able to reproduce? If so, can you provide me with a 
reproducer?

> MQTT connection failure handling may lead to NPE
> ------------------------------------------------
>
>                 Key: ARTEMIS-2782
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-2782
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>    Affects Versions: 2.11.0
>            Reporter: Keith Wall
>            Priority: Major
>
> 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:
> {noformat}
> 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)
> {noformat}
>  
> 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.  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to