You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/06/29 13:40:34 UTC
[commons-pool] 04/04: Change new method from protected to package
private to reduce client API footprint.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-pool.git
commit 80652305f97f87c611d25d0d13f4f96545c9ab75
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jun 29 09:27:11 2021 -0400
Change new method from protected to package private to reduce client API
footprint.
---
.../commons/pool2/impl/BaseGenericObjectPool.java | 44 ++++++++++++----------
1 file changed, 25 insertions(+), 19 deletions(-)
diff --git a/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java b/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
index c0dbe12..f5efecb 100644
--- a/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
@@ -447,6 +447,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.
* @throws Exception if an error occurs creating idle instances
@@ -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;
- }
-
}