GitHub user dbantchovski opened a pull request:
https://github.com/apache/httpcore/pull/22
Asymetric number of invocations of onLease/onRelease in conn pool
Hi colleagues,
I am investigating a connection leak problem in a library that, uses apache
httpclient. To track the issue I have to set the logging severity to DEBUG in
order to log connection management events as it is described here
http://hc.apache.org/httpcomponents-client-ga/logging.html . This is not a
valid option for me, since I have several apache http client instances on my
setup, and I would like to trace all connection pool activities on exactly one
particular instance. So, I decided to modify the httpclient in the following
way: each time when а connection is taken from the pool to obtain the
stacktrace of the caller, it is put in a map that is the mapping connection ID
is put in the caller stacktrace. Then, when a connection is returned back to
the pool just to remove the corresponding mapping. In this way I will always
have the stacktrace of all leased connections.
Looking at the httpclient code â org.apache.http.pool.AbstractConnPool I
found two very convenient methods:
protected void onLease(final E entry) {
}
protected void onRelease(final E entry) {
}
I found this problem: The number of onLease invocation calls is not equal
to the number of onRelease call. On the other hand, the number of leased
connection reported by getTotalStats() is correct. Looking at the code, I found
that onRelease has been invoked conditionally, which is not the correct
behavior.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/dbantchovski/httpcore 4.3.x
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/httpcore/pull/22.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #22
----
commit 54567ce0b21cf8eccde5f2e8ea04674635a1b103
Author: Desislav Bantchovski <[email protected]>
Date: 2016-03-10T15:35:23Z
Asymetric number of invocations of onLease/onRelease in conn pool
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]