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

Missing shutdown of asyncSupport in case of fallback to other implementation #649

Closed
javaguru-ch opened this issue Sep 26, 2012 · 2 comments
Labels

Comments

@javaguru-ch
Copy link

If an instance of Tomcat7AsyncSupportWithWebSocket is created first and later on replaced with an instance of Tomcat7BIOSupportWithWebSocket, the first instance is not destroyed.

Log:

12:35:47.533 WARN o.atmosphere.cpr.AtmosphereFramework - Failed using comet support: org.atmosphere.container.Tomcat7AsyncSupportWithWebSocket, error: Tomcat failed to detect this is a Comet application because context.xml is missing or the Http11NioProtocol Connector is not enabled.
If that's not the case, you can also remove META-INF/context.xml and WEB-INF/lib/atmosphere-compat-tomcat.jar Is the Nio or Apr Connector enabled?
12:36:24.470 WARN o.atmosphere.cpr.AtmosphereFramework - Using org.atmosphere.container.Tomcat7BIOSupportWithWebSocket

The problem lies in class AtmosphereFramework on line 1303:

asyncSupport = asyncSupport.supportWebSocket() ? new Tomcat7BIOSupportWithWebSocket(config) : new BlockingIOCometSupport(config);

Before replacing the current (not working) asyncSupport, it should be shut down to ensure all resources (i.e. ExecutorService) are properly shut down.
A possible solution would be to replace the above line with the following code:

AsyncSupport current = asyncSupport;
asyncSupport = asyncSupport.supportWebSocket() ? new Tomcat7BIOSupportWithWebSocket(config) : new BlockingIOCometSupport(config);
if(current instanceof AsynchronousProcessor) {
    ((AsynchronousProcessor)current).shutdown();
}
@jfarcand
Copy link
Member

Good catch! Testing it.

jfarcand added a commit that referenced this issue Sep 26, 2012
@jfarcand
Copy link
Member

Thanks! Adding in 1.1-SNAPSHOT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants