Skip to content

Commit b8b5ffd

Browse files
committed
Type to the interface where we can
- Reduce visibility of some private class' methods - Javadoc
1 parent 336937a commit b8b5ffd

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/main/java/org/apache/commons/pool3/impl/GenericKeyedObjectPool.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.NoSuchElementException;
2929
import java.util.Objects;
3030
import java.util.TreeMap;
31+
import java.util.concurrent.BlockingDeque;
3132
import java.util.concurrent.ConcurrentHashMap;
3233
import java.util.concurrent.TimeUnit;
3334
import java.util.concurrent.atomic.AtomicBoolean;
@@ -136,37 +137,37 @@ private static final class ObjectDeque<S> {
136137
/**
137138
* Gets all the objects for the current key.
138139
*
139-
* @return All the objects
140+
* @return All the objects.
140141
*/
141-
public Map<IdentityWrapper<S>, PooledObject<S>> getAllObjects() {
142+
Map<IdentityWrapper<S>, PooledObject<S>> getAllObjects() {
142143
return allObjects;
143144
}
144145

145146
/**
146147
* Gets the number of instances created - number destroyed.
147148
* Should always be less than or equal to maxTotalPerKey.
148149
*
149-
* @return The net instance addition count for this deque
150+
* @return The net instance addition count for this deque.
150151
*/
151-
public AtomicInteger getCreateCount() {
152+
AtomicInteger getCreateCount() {
152153
return createCount;
153154
}
154155

155156
/**
156157
* Gets the idle objects for the current key.
157158
*
158-
* @return The idle objects
159+
* @return The idle objects.
159160
*/
160-
public LinkedBlockingDeque<PooledObject<S>> getIdleObjects() {
161+
LinkedBlockingDeque<PooledObject<S>> getIdleObjects() {
161162
return idleObjects;
162163
}
163164

164165
/**
165166
* Gets the number of threads with an interest registered in this key.
166167
*
167-
* @return The number of threads with a registered interest in this key
168+
* @return The number of threads with a registered interest in this key.
168169
*/
169-
public AtomicLong getNumInterested() {
170+
AtomicLong getNumInterested() {
170171
return numInterested;
171172
}
172173

@@ -306,7 +307,7 @@ public GenericKeyedObjectPool(final KeyedPooledObjectFactory<K, T, E> factory,
306307
private void addIdleObject(final K key, final PooledObject<T> p) throws E {
307308
if (PooledObject.nonNull(p)) {
308309
factory.passivateObject(key, p);
309-
final LinkedBlockingDeque<PooledObject<T>> idleObjects = poolMap.get(key).getIdleObjects();
310+
final BlockingDeque<PooledObject<T>> idleObjects = poolMap.get(key).getIdleObjects();
310311
if (getLifo()) {
311312
idleObjects.addFirst(p);
312313
} else {
@@ -617,7 +618,7 @@ public void clear(final K key, final boolean reuseCapacity) {
617618
final ObjectDeque<T> objectDeque = register(key);
618619
int freedCapacity = 0;
619620
try {
620-
final LinkedBlockingDeque<PooledObject<T>> idleObjects = objectDeque.getIdleObjects();
621+
final BlockingDeque<PooledObject<T>> idleObjects = objectDeque.getIdleObjects();
621622
PooledObject<T> p = idleObjects.poll();
622623
while (p != null) {
623624
try {
@@ -1505,7 +1506,7 @@ public void returnObject(final K key, final T obj) {
15051506
}
15061507

15071508
final int maxIdle = getMaxIdlePerKey();
1508-
final LinkedBlockingDeque<PooledObject<T>> idleObjects = objectDeque.getIdleObjects();
1509+
final BlockingDeque<PooledObject<T>> idleObjects = objectDeque.getIdleObjects();
15091510

15101511
if (isClosed() || maxIdle > -1 && maxIdle <= idleObjects.size()) {
15111512
try {
@@ -1550,9 +1551,8 @@ public void returnObject(final K key, final T obj) {
15501551
private void reuseCapacity() {
15511552
final int maxTotalPerKeySave = getMaxTotalPerKey();
15521553
int maxQueueLength = 0;
1553-
LinkedBlockingDeque<PooledObject<T>> mostLoadedPool = null;
1554+
BlockingDeque<PooledObject<T>> mostLoadedPool = null;
15541555
K mostLoadedKey = null;
1555-
15561556
// Find the most loaded pool that could take a new instance
15571557
for (final Map.Entry<K, ObjectDeque<T>> entry : poolMap.entrySet()) {
15581558
final K k = entry.getKey();
@@ -1564,7 +1564,6 @@ private void reuseCapacity() {
15641564
mostLoadedKey = k;
15651565
}
15661566
}
1567-
15681567
// Attempt to add an instance to the most loaded pool.
15691568
if (mostLoadedPool != null) {
15701569
register(mostLoadedKey);

src/main/java/org/apache/commons/pool3/impl/InterruptibleReentrantLock.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ final class InterruptibleReentrantLock extends ReentrantLock {
3737
* Constructs a new InterruptibleReentrantLock with the given fairness policy.
3838
*
3939
* @param fairness true means threads should acquire contended locks as if
40-
* waiting in a FIFO queue
40+
* waiting in a FIFO queue.
4141
*/
4242
InterruptibleReentrantLock(final boolean fairness) {
4343
super(fairness);
4444
}
4545

4646
/**
47-
* Interrupts the threads that are waiting on a specific condition
47+
* Interrupts the threads that are waiting on a specific condition.
4848
*
4949
* @param condition the condition on which the threads are waiting.
5050
*/

src/main/java/org/apache/commons/pool3/impl/SoftReferenceObjectPool.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.NoSuchElementException;
2525
import java.util.Objects;
2626
import java.util.Optional;
27+
import java.util.concurrent.BlockingDeque;
2728

2829
import org.apache.commons.pool3.BaseObjectPool;
2930
import org.apache.commons.pool3.ObjectPool;
@@ -65,7 +66,7 @@ public class SoftReferenceObjectPool<T, E extends Exception> extends BaseObjectP
6566
private long createCount; // @GuardedBy("this")
6667

6768
/** Idle references - waiting to be borrowed */
68-
private final LinkedBlockingDeque<PooledSoftReference<T>> idleReferences = new LinkedBlockingDeque<>();
69+
private final BlockingDeque<PooledSoftReference<T>> idleReferences = new LinkedBlockingDeque<>();
6970

7071
/** All references - checked out or waiting to be borrowed. */
7172
private final ArrayList<PooledSoftReference<T>> allReferences = new ArrayList<>();

0 commit comments

Comments
 (0)