Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
spring-projects-issues opened this issue Aug 31, 2010 · 1 comment
Closed
Assignees
Labels
in: messaging Issues in messaging modules (jms, messaging) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

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

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Fixed for 3.0.5 through using a finally block, as suggested.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: messaging Issues in messaging modules (jms, messaging) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants