Skip to content

Commit

Permalink
fixed request leak
Browse files Browse the repository at this point in the history
  • Loading branch information
hiteshk25 committed Oct 30, 2024
1 parent 68a4e64 commit 51a3708
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ private boolean acquire(RequestPriorities priority) throws InterruptedException
CountDownLatch wait = new CountDownLatch(1);
this.waitingList.put(wait);
long startTime = System.nanoTime();
return wait.await(this.waitTimeoutInNanos, TimeUnit.NANOSECONDS)
&& nextInQueue(this.waitTimeoutInNanos - (System.nanoTime() - startTime));
if (wait.await(this.waitTimeoutInNanos, TimeUnit.NANOSECONDS)) {
return nextInQueue(this.waitTimeoutInNanos - (System.nanoTime() - startTime));
} else {
// remove from the queue; this/other requests already waited long enough; thus best effort
this.waitingList.poll();
return false;
}
}
}
return true;
Expand Down

0 comments on commit 51a3708

Please sign in to comment.