Skip to content

DefaultMessageListenerContainer may hang on shutdown [SPR-7511] #12168

@spring-projects-issues

Description

@spring-projects-issues

Dennis Homann opened SPR-7511 and commented

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

Thread-0@6084, 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.


Affects: 2.5.6

Referenced from: commits d7e0776

Metadata

Metadata

Assignees

Labels

in: messagingIssues in messaging modules (jms, messaging)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions