Change new method from protected to package private to reduce client API
footprint.
@@ -446,6 +446,27 @@ public abstract class BaseGenericObjectPool<T> extends BaseObject {
*/
public abstract void close();
+ /**
+ * Creates a list of pooled objects to remove based on their state.
+ * @param abandonedConfig The abandoned configuration.
+ * @param allObjects PooledObject instances to consider.
+ * @return a list of pooled objects to remove based on their state.
+ */
+ ArrayList<PooledObject<T>> createRemoveList(final AbandonedConfig abandonedConfig, final Map<IdentityWrapper<T>, PooledObject<T>> allObjects) {
+ final Instant timeout = Instant.now().minus(abandonedConfig.getRemoveAbandonedTimeoutDuration());
+ final ArrayList<PooledObject<T>> remove = new ArrayList<>();
+ allObjects.values().forEach(pooledObject -> {
+ synchronized (pooledObject) {
+ if (pooledObject.getState() == PooledObjectState.ALLOCATED &&
+ pooledObject.getLastUsedInstant().compareTo(timeout) <= 0) {
+ pooledObject.markAbandoned();
+ remove.add(pooledObject);
+ }
+ }
+ });
+ return remove;
+ }
+
/**
* Tries to ensure that the configured minimum number of idle instances are
* available in the pool.
@@ -1057,6 +1078,8 @@ public abstract class BaseGenericObjectPool<T> extends BaseObject {
return timeBetweenEvictionRuns.toMillis();
}
+ // Monitoring (primarily JMX) related methods
+
/**
* Gets whether or not abandoned object removal is configured for this pool.
*
@@ -1068,8 +1091,6 @@ public abstract class BaseGenericObjectPool<T> extends BaseObject {
return abandonedConfig != null;
}
- // Monitoring (primarily JMX) related methods
-
/**
* Has this pool instance been closed.
* @return {@code true} when this pool has been closed.
@@ -1481,6 +1502,8 @@ public abstract class BaseGenericObjectPool<T> extends BaseObject {
this.softMinEvictableIdleTime = PoolImplUtils.nonNull(softMinEvictableIdleTime, BaseObjectPoolConfig.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME);
}
+ // Inner classes
+
/**
* Sets the minimum amount of time an object may sit idle in the pool
* before it is eligible for eviction by the idle object evictor (if any -
@@ -1504,8 +1527,6 @@ public abstract class BaseGenericObjectPool<T> extends BaseObject {
setSoftMinEvictableIdleTime(Duration.ofMillis(softMinEvictableIdleTimeMillis));
}
- // Inner classes
-
/**
* The listener used (if any) to receive notifications of exceptions
* unavoidably swallowed by the pool.
@@ -1792,20 +1813,5 @@ public abstract class BaseGenericObjectPool<T> extends BaseObject {
activeTimes.add(activeTime);
}
- protected ArrayList<PooledObject<T>> createRemoveList(final AbandonedConfig abandonedConfig, final Map<IdentityWrapper<T>, PooledObject<T>> allObjects) {
- final Instant timeout = Instant.now().minus(abandonedConfig.getRemoveAbandonedTimeoutDuration());
- final ArrayList<PooledObject<T>> remove = new ArrayList<>();
- allObjects.values().forEach(pooledObject -> {
- synchronized (pooledObject) {
- if (pooledObject.getState() == PooledObjectState.ALLOCATED &&
- pooledObject.getLastUsedInstant().compareTo(timeout) <= 0) {
- pooledObject.markAbandoned();
- remove.add(pooledObject);
- }
- }
- });
- return remove;
- }
-
}
