Skip to content

Commit

Permalink
GH-3826: Fix reducePermits
Browse files Browse the repository at this point in the history
Must not go negative.
  • Loading branch information
garyrussell committed Jun 27, 2022
1 parent 6fe59a7 commit 979b841
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ public synchronized void close() {
removeAllIdleItems();
}

@SuppressWarnings("serial")
private static class PoolSemaphore extends Semaphore {

PoolSemaphore(int permits) {
Expand All @@ -280,7 +281,7 @@ private static class PoolSemaphore extends Semaphore {

@Override
public void reducePermits(int reduction) { // NOSONAR increases visibility
super.reducePermits(reduction);
super.reducePermits(reduction > availablePermits() ? availablePermits() : reduction);
}

}
Expand Down

0 comments on commit 979b841

Please sign in to comment.