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

HttpComponentsHttpInvokerRequestExecutor does not explicitly release connection [SPR-9833] #14466

Closed
spring-projects-issues opened this issue Sep 26, 2012 · 2 comments
Assignees
Labels
in: web type: bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Sep 26, 2012

Gerrit Brehmer opened SPR-9833 and commented

We are using HttpComponentsHttpInvokerRequestExecutor with HttpClient v4.2.1 with PoolingClientConnectionManager. We notice in our live environment, that in case of an error, the connection is not gracefully released.
I have attached a TestCase. The first one consumes the entity at the end (by default there are callback handler registered, which releases the connection after consuming the entity). Otherwise explicitly releasing connection is also possible to fix the problem.
But currently the HttpComponentsHttpInvokerRequestExecutor does not consume the entity after an HTTP error (or releasing connection explicitly) so the connection is not released and not available for other requests.


Affects: 3.1.2

Attachments:

Issue Links:

  • #14110 Upgrade commons-httpclient from version 4.1 to version 4.2

Referenced from: commits 6ed589d, 93aa411

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 26, 2012

Gerrit Brehmer commented

Fix is quite simple:

    protected RemoteInvocationResult doExecuteRequest(
            HttpInvokerClientConfiguration config, ByteArrayOutputStream baos)
            throws IOException, ClassNotFoundException {

        HttpPost postMethod = createHttpPost(config);
        setRequestBody(config, postMethod, baos);
        try {
            HttpResponse response = executeHttpPost(config, getHttpClient(), postMethod);
            validateResponse(config, response);
            InputStream responseBody = getResponseBody(config, response);
            return readRemoteInvocationResult(responseBody, config.getCodebaseUrl());
        } finally {
            postMethod.releaseConnection();
        }
    }

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 26, 2012

Juergen Hoeller commented

Good catch! I've addressed this through using HttpComponents 4.2's PoolingClientConnectionManager and the HttpPost.releaseConnection() now, which also got introduced as late as HttpComponents 4.2. Since Spring 3.1 aims to be compatible with HttpComponents 4.0 and higher, we're calling the releaseConnection method reflectively there if available. Spring 3.2 requires HttpComponents 4.2, so it's more straightforward there.

Juergen

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

No branches or pull requests

2 participants