ARTEMIS - java.lang.NullPointerException switching subscription with #

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ARTEMIS - java.lang.NullPointerException switching subscription with #

francesco81
Hi,
I'm facing an issue when switching a topic subscription from the full path to the "wildcard char" one (with '#') and viceversa.
I'm using the last 2.1.0 version (downloaded from activemq.apache.org). Here my test:

1) connect to Artemis
2) subscribe a topic by using full path, eg. "/prj/plantid/111111/gwid/22222/connection_state"
3) disconnect and reconnect to Artemis
4) subscribe to a topic by using the wildcard char '#', eg. "/prj/plantid/111111/gwid/22222/#"
5) disconnect and reconnect to Artemis
6) as in step 2, subscribe a topic by using full path, eg. "/prj/plantid/111111/gwid/22222/connection_state" --> Artemis doesn't let subscribe and close my client connection
NOTE: it seems that the problem affects only the LWT topic (in my example "/prj/plantid/111111/gwid/22222/connection_state" is an lwt topic).

By setting artemis.log to trace I see the following error:

08:38:44,122 DEBUG [io.netty.handler.ssl.SslHandler] [id: 0x41543b32, L:/172.16.2.5:8884 - R:/54.76.160.93:58198] HANDSHAKEN: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
08:38:44,123 DEBUG [org.apache.activemq.artemis.core.protocol.mqtt] SESSION CREATED: 993619fb-372e-47f0-889e-ab1394e9b9e7
08:38:44,125 DEBUG [org.apache.activemq.artemis.core.protocol.mqtt] Error processing Control Packet, Disconnecting Client: java.lang.NullPointerException
        at org.apache.activemq.artemis.core.postoffice.impl.WildcardAddressManager.addBinding(WildcardAddressManager.java:95) [artemis-server-2.1.0.jar:2.1.0]
        at org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl.addBinding(PostOfficeImpl.java:529) [artemis-server-2.1.0.jar:2.1.0]
        at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.createQueue(ActiveMQServerImpl.java:2582) [artemis-server-2.1.0.jar:2.1.0]
        at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.createQueue(ActiveMQServerImpl.java:1588) [artemis-server-2.1.0.jar:2.1.0]
        at org.apache.activemq.artemis.core.server.impl.ServerSessionImpl.createQueue(ServerSessionImpl.java:558) [artemis-server-2.1.0.jar:2.1.0]
        at org.apache.activemq.artemis.core.server.impl.ServerSessionImpl.createQueue(ServerSessionImpl.java:597) [artemis-server-2.1.0.jar:2.1.0]
        at org.apache.activemq.artemis.core.protocol.mqtt.MQTTSubscriptionManager.findOrCreateQueue(MQTTSubscriptionManager.java:121) [artemis-mqtt-protocol-2.1.0.jar:]
        at org.apache.activemq.artemis.core.protocol.mqtt.MQTTSubscriptionManager.createQueueForSubscription(MQTTSubscriptionManager.java:113) [artemis-mqtt-protocol-2.1.0.jar:]
        at org.apache.activemq.artemis.core.protocol.mqtt.MQTTSubscriptionManager.addSubscription(MQTTSubscriptionManager.java:172) [artemis-mqtt-protocol-2.1.0.jar:]
        at org.apache.activemq.artemis.core.protocol.mqtt.MQTTSubscriptionManager.addSubscriptions(MQTTSubscriptionManager.java:222) [artemis-mqtt-protocol-2.1.0.jar:]
        at org.apache.activemq.artemis.core.protocol.mqtt.MQTTProtocolHandler.handleSubscribe(MQTTProtocolHandler.java:250) [artemis-mqtt-protocol-2.1.0.jar:]
        at org.apache.activemq.artemis.core.protocol.mqtt.MQTTProtocolHandler.channelRead(MQTTProtocolHandler.java:132) [artemis-mqtt-protocol-2.1.0.jar:]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1240) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1041) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:1017) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:394) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:299) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [netty-all-4.1.9.Final.jar:4.1.9.Final]
        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_111]

08:38:44,128 DEBUG [org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl] PostOffice notification / BINDING_REMOVED: Cannot find queue info for queue " + clusterName
08:38:44,129 DEBUG [org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl] Couldn't find any bindings for address=activemq.notifications on message=CoreMessage[messageID=727,durable=true,userID=null,priority=0, timestamp=0,expiration=Mon Jun 05 08:38:44 UTC 2017, durable=true, address=activemq.notifications,properties=TypedProperties[_AMQ_RoutingName=franzsub..cro.plantid.1101937.gwid.49180.connection_state,_AMQ_Distance=0,_AMQ_Address=.cro.plantid.1101937.gwid.49180.connection_state,_AMQ_NotifType=BINDING_REMOVED,_AMQ_Binding_ID=723,_AMQ_FilterString=NOT ((AMQAddress = 'activemq.management') OR (AMQAddress = 'activemq.notifications')),_AMQ_NotifTimestamp=1496047124128,_AMQ_ClusterName=franzsub..cro.plantid.1101937.gwid.49180.connection_statecdf4c005-4449-11e7-b990-069133a4f5cf]]@23377517
08:38:44,129 DEBUG [org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl] Message CoreMessage[messageID=727,durable=true,userID=null,priority=0, timestamp=0,expiration=Mon Jun 05 08:38:44 UTC 2017, durable=true, address=activemq.notifications,properties=TypedProperties[_AMQ_RoutingName=franzsub..cro.plantid.1101937.gwid.49180.connection_state,_AMQ_Distance=0,_AMQ_Address=.cro.plantid.1101937.gwid.49180.connection_state,_AMQ_NotifType=BINDING_REMOVED,_AMQ_Binding_ID=723,_AMQ_FilterString=NOT ((AMQAddress = 'activemq.management') OR (AMQAddress = 'activemq.notifications')),_AMQ_NotifTimestamp=1496047124128,_AMQ_ClusterName=franzsub..cro.plantid.1101937.gwid.49180.connection_statecdf4c005-4449-11e7-b990-069133a4f5cf]]@23377517 is not going anywhere as it didn't have a binding on address:activemq.notifications
08:38:44,129 DEBUG [org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl] RemotingServiceImpl::removing connection ID 1746351574


Any idea?
Thanks to anyone for the help.

Francesco
Reply | Threaded
Open this post in threaded view
|

Re: ARTEMIS - java.lang.NullPointerException switching subscription with #

francesco81
Hi, just an update.
We found out that there was a client subscribed to the incriminated topic with a double wildcard char: "/prj/plantid/+/gwid/+/connection_state". So, there is a step 0 to add to the ones in my previous post: "0) connect a client and subscribe the topic /prj/plantid/+/gwid/+/connection_state". It seems that it breaks something somewhere.
When, in a second moment, I subscribe the punctual topic "/prj/plantid/111111/gwid/22222/connection_state" and the generic one "/prj/plantid/111111/gwid/22222/#", after the disconnection it is no more possible to subscribe the specific one.
It seems like the unsubscribe method doesn't free the "link" between the punctual address and the generic one. Thus, any following subscribe event to the punctual topic throws a nullPointer exception.

Is it possible that something is wrong in the "WildcardAddressManager.java" class, for methods "private synchronized void removeAndUpdateAddressMap(final Address address) throws Exception" and "public boolean addBinding(final Binding binding) throws Exception"?

Francesco
Reply | Threaded
Open this post in threaded view
|

Re: ARTEMIS - java.lang.NullPointerException switching subscription with #

francesco81
Attached you can find a junit to replicate the issue.
Cheers.

Francesco

PahoMQTTWildcardTest.java