[SWS-564] CommonsHttpMessageSender no longer properly shuts down MultiThreadedHttpConnectionManager Created: 09/Sep/09  Updated: 04/May/12  Resolved: 10/Nov/09

Status: Closed
Project: Spring Web Services
Component/s: None
Affects Version/s: None
Fix Version/s: 1.5.9

Type: Bug Priority: Major
Reporter: Nicholas Blair Assignee: Arjen Poutsma
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0d
Time Spent: 4h 5m
Original Estimate: Not Specified

Issue Links:
is related to SWS-482 java.lang.IllegalStateException: Conn... Closed


As of revision 1414 of CommonsHttpMessageSender, the MultiThreadedHttpConnectionManager never gets it's shutdown method invoked.

It appears that the prior revision of CommonsHttpMessageSender implemented DisposableBean, and invoked this properly.
SWS-482 removed the destroy method to cope with a problem report, but the result is worse.

If you use MultiThreadedHttpConnectionManager, you have to call it's shutdown method, or it will block application exit.
For example, I have a class with a main method that uses WebServiceTemplate along with CommonsHttpMessageSender that is invoked via an ant task. The main method will complete, but the JVM cannot exit.

Lets revisit SWS-482 and come up with a means for resolving the issue appropriately.
The reporter of that issue mentions that:
"it happens it is always after we redeploy our application (weblogic 9.2MP2)".

Comment by Nicholas Blair [ 09/Sep/09 ]

The problem reported in SWS-482 is likely due to the following sequence of events (with the prior revision of CommonsHttpMessageSender):

1. Customer tries to redeploy application using WebServiceTemplate and CommonsHttpMessageSender.
2. redeploy results in first stopping application, which shuts down Spring application context.
3. destroy in WebServiceTemplate results in CommonsHttpMessageSender#destroy
4. CommonsHttpMessageSender destroy results in MultiThreadedHttpConnectionManager#shutdown
5. Application shutdown, now started again by the container.

I think the actual solution here isn't to remove DisposableBean (and the MultiThreadedHttpConnectionManager#shutdown) implementation on CommonsHttpMessageSender.

One option might be to alter CommonsHttpMessageSender's afterPropertiesSet method - it should instantiate a new MultiThreadedHttpConnectionManager and supply it to the internal HttpClient.

Comment by Arjen Poutsma [ 10/Sep/09 ]

Good suggestions, I will take a further look at this for 1.5.9.


Comment by Arjen Poutsma [ 10/Nov/09 ]

I reintroduced the shutdown() call, and also solved the problem reported in SWS-482.

The underlying problem (in SWS-482) was that a connection was retrieved from the CommonsHttpMessageSender, the app context was closed resulting in a the connection pool shutdown, and then the connection was used, resulting in the IllegalStateException. Now, we create a new, single-use connection pool for that connection. Not pretty, but it works.

Comment by Arjen Poutsma [ 04/May/12 ]

Closing old issues

Generated at Wed Jun 19 03:48:09 UTC 2019 using JIRA 7.9.2#79002-sha1:3bb15b68ecd99a30eb364c4c1a393359bcad6278.