Skip to content

Configure the used HttpClient to be thread-safe#17

Open
msiuts wants to merge 1 commit intoSilverpop:masterfrom
scoyo:Issue16
Open

Configure the used HttpClient to be thread-safe#17
msiuts wants to merge 1 commit intoSilverpop:masterfrom
scoyo:Issue16

Conversation

@msiuts
Copy link
Contributor

@msiuts msiuts commented May 14, 2014

This fixes #16 (#16).
Using the ApiClient in a multi-threaded environment can lead to an exception and this warning:

WARN org.apache.commons.httpclient.SimpleHttpConnectionManager - SimpleHttpConnectionManager being used incorrectly. Be sure that HttpMethod.releaseConnection() is always called and that only one thread and/or method is using this connection manager at a time.

To fix this issue the HttpClient is now constructed with a MultiThreadedHttpConnectionManager. Also it is taken care, that releaseConnection() is called after excuting a HttpMethod. To ensure this the scope of the httpClient and the executeMethod() is narrowed to private.

For details on how to use HttpClient safely from within a multi-threaded environment see:
http://hc.apache.org/httpclient-3.x/threading.html

This fixes Silverpop#16 (Silverpop#16).
Using the ApiClient in a multi-threaded environment can lead to an exception and this warning:

WARN org.apache.commons.httpclient.SimpleHttpConnectionManager  - SimpleHttpConnectionManager being used incorrectly.  Be sure that HttpMethod.releaseConnection() is always called and that only one thread and/or method is using this connection manager at a time.

To fix this issue the HttpClient is now constructed with a MultiThreadedHttpConnectionManager. Also it is taken care, that releaseConnection() is called after excuting a HttpMethod. To ensure this the scope of the httpClient and the executeMethod() is narrowed to private.

For details on  how to use HttpClient safely from within a multi-threaded environment see:
http://hc.apache.org/httpclient-3.x/threading.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XmlApiClient is not thread safe

1 participant