Skip to content

XmlApiClient is not thread safe #16

@msiuts

Description

@msiuts

The XmlApiClient is not threadsafe because the constructor calls this super-constructor:

protected ApiClient(ApiCommandProcessor<REQUEST> commandProcessor, ApiSession session) {
        this(commandProcessor, new HttpClient(), session);
    }

The problem here is, that new HttpClient() constructs a HttpClient with a SimpleHttpConnectionManager and this can cause an Exception and this log message:

  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.

In my opinion the HttpClient which is used should be injected and build and configured elsewhere. Or it should be constructed with a MultiThreadedHttpConnectionManager.

But maybe the whole ApiClient is not meant to be threadsafe - that's why I'd like to discuss this issue before implementing a fix. What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions