GH-3826: Fix reducePermits

Must not go negative.
This commit is contained in:
Gary Russell
2022-06-27 14:37:17 -04:00
parent d3bf48ca3f
commit ecb04bbb54

View File

@@ -272,6 +272,7 @@ public class SimplePool<T> implements Pool<T> {
removeAllIdleItems();
}
@SuppressWarnings("serial")
private static class PoolSemaphore extends Semaphore {
PoolSemaphore(int permits) {
@@ -280,7 +281,7 @@ public class SimplePool<T> implements Pool<T> {
@Override
public void reducePermits(int reduction) { // NOSONAR increases visibility
super.reducePermits(reduction);
super.reducePermits(reduction > availablePermits() ? availablePermits() : reduction);
}
}