Skip to content

Commit

Permalink
HTTPCLIENT-2298: Strict connection pool to filter out expired and com…
Browse files Browse the repository at this point in the history
…pleted requests from the pool stats
  • Loading branch information
ok2c committed Sep 25, 2023
1 parent e3c770b commit 371347a
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,18 @@ public int getMaxPerRoute(final T route) {
public PoolStats getTotalStats() {
this.lock.lock();
try {
int pendingCount = 0;
for (final LeaseRequest<T, C> request: pendingRequests) {
if (!request.isDone()) {
final Deadline deadline = request.getDeadline();
if (!deadline.isExpired()) {
pendingCount++;
}
}
}
return new PoolStats(
this.leased.size(),
this.pendingRequests.size(),
pendingCount,
this.available.size(),
this.maxTotal);
} finally {
Expand All @@ -536,8 +545,11 @@ public PoolStats getStats(final T route) {
final PerRoutePool<T, C> pool = getPool(route);
int pendingCount = 0;
for (final LeaseRequest<T, C> request: pendingRequests) {
if (Objects.equals(route, request.getRoute())) {
pendingCount++;
if (!request.isDone() && Objects.equals(route, request.getRoute())) {
final Deadline deadline = request.getDeadline();
if (!deadline.isExpired()) {
pendingCount++;
}
}
}
return new PoolStats(
Expand Down

0 comments on commit 371347a

Please sign in to comment.