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

When SimpleMessageListenerContainer could not connect, it throws a NullPointerException in shutdown() [SPR-9930] #14563

Closed
spring-projects-issues opened this issue Oct 30, 2012 · 0 comments
Assignees
Labels
in: messaging type: bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Oct 30, 2012

Geert Pante opened SPR-9930 and commented

When I start a simpleMessageListenerContainer while the ActiveMQ server is down, I get:

to perform GET on: http://localhost:22012 as response was: Connection to http://localhost:22012 refused
        at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:35)
        at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:295)
        at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:239)
        at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:185)
        at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)
        at org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:403)
        at org.springframework.jms.listener.AbstractJmsListeningContainer.establishSharedConnection(AbstractJmsListeningContainer.java:371)
        at org.springframework.jms.listener.SimpleMessageListenerContainer.doInitialize(SimpleMessageListenerContainer.java:187)

        at org.springframework.jms.listener.AbstractJmsListeningContainer.initialize(AbstractJmsListeningContainer.java:193)
        ... 10 more

I can catch this exception, and the container will keep retrying, which is a good thing.

If I want to shut it down, I do

try
{
    if (jmsContainer.isRunning())
    {
        jmsContainer.stop();
    }
    jmsContainer.destroy();
    jmsContainer = null;
}
catch (JmsException e)
{
    log.warn("Exception stopping listener: ", e);
}

But here I get a NullPointerException from the destroy():

Caused by: java.lang.NullPointerException
        at org.springframework.jms.listener.SimpleMessageListenerContainer.doShutdown(SimpleMessageListenerContainer.java:325)
        at org.springframework.jms.listener.AbstractJmsListeningContainer.shutdown(AbstractJmsListeningContainer.java:231)
        at org.springframework.jms.listener.AbstractJmsListeningContainer.destroy(AbstractJmsListeningContainer.java:172)

Apparently, this.consumers and this.sessions are null, while you try to iterate over them.


Affects: 3.0.7

@spring-projects-issues spring-projects-issues added type: bug in: messaging labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.1.3 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: messaging type: bug
Projects
None yet
Development

No branches or pull requests

2 participants