Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-7511

DefaultMessageListenerContainer may hang on shutdown

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 2.5.6
    • Fix Version/s: 3.0.5
    • Component/s: JMS
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      DefaultMessageListenerContainer does not reliably manage its activeInvokerCount, which may prevent it from shutting down. Instead, it will wait indefinitely in

      [email protected], prio=5, in group 'main', status: 'WAIT'
      	  at java.lang.Object.wait(Object.java:-1)
      	  at java.lang.Object.wait(Object.java:485)
      	  at org.springframework.jms.listener.DefaultMessageListenerContainer.doShutdown(DefaultMessageListenerContainer.java:489)
      	  at org.springframework.jms.listener.AbstractJmsListeningContainer.shutdown(AbstractJmsListeningContainer.java:211)
      	  at org.springframework.jms.listener.AbstractJmsListeningContainer.destroy(AbstractJmsListeningContainer.java:149)
      

      In org.springframework.jms.listener.DefaultMessageListenerContainer.AsyncMessageListenerInvoker#run, #decreateActiveInvokerCount will never be called, if an exception is thrown from within the catch(Throwable ex) block, lines 886-908.

      In the case at hand, a NPE is caused by https://jira.springframework.org/browse/SPR-5470, which has been fixed in 3.0, but not in 2.5.x. Other runtime exceptions are imaginable as well. This issue is fairly reproducible with an embedded ActiveMQ broker which is shut down at the same time as the listener (may cause JMSExceptions in the listener).
      To fix this issue, I suggest to use a finally block in order to decrement the active invoker count, and perform other clean up as necessary.

        Attachments

          Activity

            People

            • Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              dhomann Dennis Homann
              Last updater:
              Trevor Marshall
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                8 years, 10 weeks, 1 day ago