Uploaded image for project: 'ActiveMQ Artemis'
  1. ActiveMQ Artemis
  2. ARTEMIS-1670

NPE was found in when dropping durable subscriptions from a topic

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.5.5
    • None
    • Broker
    • None

    Description

      In WildFly, set up a topic by executing following CLI:

      /subsystem=messaging-activemq/server=default:write-attribute(name=security-enabled,value=false)
      :reload
      /subsystem=messaging-activemq/server=default/jms-topic=testTopic:add(entries=[java:/jms/topic/testTopic, java:jboss/exported/jms/topic/testTopic])
      

      Then create a durable subscriber on it using the following test code:
       

          public static void main(String[] args) throws Exception {
          	Connection connection = null;
              Context namingContext = null;
              try {
                  final Properties env = new Properties();
                  env.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
                  env.put(Context.PROVIDER_URL, System.getProperty(Context.PROVIDER_URL, "http-remoting://127.0.0.1:8080"));
                  namingContext = new InitialContext(env);
                  Topic topic = (Topic) namingContext.lookup("/jms/topic/testTopic");
                  ConnectionFactory connectionFactory = (ConnectionFactory) namingContext.lookup("jms/RemoteConnectionFactory");
                  connection = connectionFactory.createConnection();
                  connection.setClientID("durable-client");
                  connection.start();
                  Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                  MessageProducer messageProducer = session.createProducer(topic);
                  TopicSubscriber subscriber = session.createDurableSubscriber(topic, "subscriber-1");
                  TextMessage message1 = session.createTextMessage("This is a text message 1");
                  messageProducer.send(message1);
                  System.out.println("Sent message: " + message1.getText());
                  TextMessage messageReceived = (TextMessage) subscriber.receive();
                  System.out.println("Received message: " + messageReceived.getText());
      
                  try {
      				Thread.sleep(20000); // wait 20 seconds before un-subscribe
      			} catch (InterruptedException e) {
      				e.printStackTrace();
      			}
                  subscriber.close();
                  session.unsubscribe("subscriber-1");
              } finally {
      			if (connection != null) {
      				connection.close();
      			}
                  if (namingContext != null) {
                  	namingContext.close();
                  }
              }
          }
      

       
      The code above will sleep 20 seconds before un-subscribe, try to execute the following WildFly CLI within 20 seconds:

      /subsystem=messaging-activemq/server=default/jms-topic=testTopic:drop-durable-subscription(client-id=durable-client, subscription-name=subscriber-1)
      

       
      The WildFly CLI succeeded, but there is a NPE in the server log:

      09:10:42,340 ERROR [org.apache.activemq.artemis.core.server] (Thread-3 (ActiveMQ-server-org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl$3@7ba46694)) AMQ224065: Failed to remove auto-created queue testSubscriberClientIdjmsTopicOperations.testSubscriber: java.lang.NullPointerException
      	at org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl$JMSQueueDeleter.delete(JMSServerManagerImpl.java:1669) [artemis-jms-server-1.5.5.008-redhat-1.jar:1.5.5.008-redhat-1]
      	at org.apache.activemq.artemis.core.server.impl.AutoCreatedQueueManagerImpl$1.run(AutoCreatedQueueManagerImpl.java:36) [artemis-server-1.5.5.008-redhat-1.jar:1.5.5.008-redhat-1]
      	at org.apache.activemq.artemis.utils.ReferenceCounterUtil.decrement(ReferenceCounterUtil.java:54) [artemis-commons-1.5.5.008-redhat-1.jar:1.5.5.008-redhat-1]
      	at org.apache.activemq.artemis.core.server.impl.AutoCreatedQueueManagerImpl.decrement(AutoCreatedQueueManagerImpl.java:58) [artemis-server-1.5.5.008-redhat-1.jar:1.5.5.008-redhat-1]
      	at org.apache.activemq.artemis.core.server.impl.QueueImpl.removeConsumer(QueueImpl.java:786) [artemis-server-1.5.5.008-redhat-1.jar:1.5.5.008-redhat-1]
      	at org.apache.activemq.artemis.core.server.impl.ServerConsumerImpl.removeItself(ServerConsumerImpl.java:496) [artemis-server-1.5.5.008-redhat-1.jar:1.5.5.008-redhat-1]
      	at org.apache.activemq.artemis.core.server.impl.ServerConsumerImpl.close(ServerConsumerImpl.java:443) [artemis-server-1.5.5.008-redhat-1.jar:1.5.5.008-redhat-1]
      	at org.apache.activemq.artemis.core.server.impl.ServerSessionImpl.closeConsumer(ServerSessionImpl.java:1174) [artemis-server-1.5.5.008-redhat-1.jar:1.5.5.008-redhat-1]
      	at org.apache.activemq.artemis.core.protocol.core.ServerSessionPacketHandler.internalHandlePacket(ServerSessionPacketHandler.java:445) [artemis-server-1.5.5.008-redhat-1.jar:1.5.5.008-redhat-1]
      	at org.apache.activemq.artemis.core.protocol.core.ServerSessionPacketHandler.lambda$handlePacket$0(ServerSessionPacketHandler.java:211) [artemis-server-1.5.5.008-redhat-1.jar:1.5.5.008-redhat-1]
      	at org.apache.activemq.artemis.utils.OrderedExecutorFactory$OrderedExecutor$ExecutorTask.run(OrderedExecutorFactory.java:122) [artemis-commons-1.5.5.008-redhat-1.jar:1.5.5.008-redhat-1]
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [rt.jar:1.8.0_151]
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [rt.jar:1.8.0_151]
      	at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_151]
      

      Despite this error, subscription is removed and listing of all subscriptions is now empty. Operation works as expected, however there is an Error logged on server side.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            lgao Lin Gao
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment