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/06 23:22:03 UTC
[commons-dbcp] 02/02: Add and reuse
InstanceKeyDataSource.{get|set}DefaultMaxWait(Duration),
deprecate .{get|set}DefaultMaxWaitMillis(long).
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-dbcp.git
commit c512dca8cebf05643a6905868f884cd909cc34ee
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jun 6 19:21:57 2021 -0400
Add and reuse InstanceKeyDataSource.{get|set}DefaultMaxWait(Duration),
deprecate .{get|set}DefaultMaxWaitMillis(long).
Javadoc.
---
src/changes/changes.xml | 18 ++++++---
.../dbcp2/datasources/InstanceKeyDataSource.java | 45 +++++++++++++++++-----
.../dbcp2/datasources/PerUserPoolDataSource.java | 12 +++---
.../dbcp2/datasources/SharedPoolDataSource.java | 2 +-
4 files changed, 54 insertions(+), 23 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 5721121..6bb24e1 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -63,22 +63,28 @@ The <action> type attribute can be add,update,fix,remove.
<release version="2.9.0" date="202Y-MM-DD" description="This is a minor release, including bug fixes and enhancements.">
<!-- ADDS -->
<action dev="ggregory" type="add" due-to="Gary Gregory">
- Add and reuse Constants.KEY_USER and Constants.KEY_PASSWORD.
+ Add and reuse Constants.KEY_USER and Constants.KEY_PASSWORD.
</action>
<action dev="ggregory" type="add" due-to="Frank Gasdorf, Gary Gregory">
- Add and reuse DataSourceMXBean.
+ Add and reuse DataSourceMXBean.
</action>
<action dev="ggregory" type="add" due-to="Gary Gregory">
- Add and reuse DriverAdapterCPDS.{get|set}DurationBetweenEvictionRuns(), deprecate {get|set}TimeBetweenEvictionRunsMillis(long).
+ Add and reuse DriverAdapterCPDS.{get|set}DurationBetweenEvictionRuns(), deprecate {get|set}TimeBetweenEvictionRunsMillis(long).
</action>
<action dev="ggregory" type="add" due-to="Gary Gregory">
- Add and reuse DriverAdapterCPDS.{get|set}MinEvictableIdleDuration(), deprecate {get|set}MinEvictableIdleTimeMillis(int).
+ Add and reuse DriverAdapterCPDS.{get|set}MinEvictableIdleDuration(), deprecate {get|set}MinEvictableIdleTimeMillis(int).
</action>
<action dev="ggregory" type="add" due-to="Gary Gregory">
- Add and reuse CPDSConnectionFactory.setMaxConnLifetime(Duration), deprecate setMaxConnLifetimeMillis(long).
+ Add and reuse CPDSConnectionFactory.setMaxConnLifetime(Duration), deprecate setMaxConnLifetimeMillis(long).
</action>
<action dev="ggregory" type="add" due-to="Gary Gregory">
- Add and reuse KeyedCPDSConnectionFactory.setMaxConnLifetime(Duration), deprecate setMaxConnLifetimeMillis(long).
+ Add and reuse KeyedCPDSConnectionFactory.setMaxConnLifetime(Duration), deprecate setMaxConnLifetimeMillis(long).
+ </action>
+ <action dev="ggregory" type="add" due-to="Gary Gregory">
+ Add and reuse KeyedCPDSConnectionFactory.setMaxConnLifetime(Duration), deprecate setMaxConnLifetimeMillis(long).
+ </action>
+ <action dev="ggregory" type="add" due-to="Gary Gregory">
+ Add and reuse InstanceKeyDataSource.{get|set}DefaultMaxWait(Duration), deprecate {get|set}DefaultMaxWaitMillis(long).
</action>
<!-- FIXES -->
<action dev="ggregory" type="fix" issue="DBCP-569" due-to="Florent Guillaume">
diff --git a/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java b/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
index e6d3893..9d2aa60 100644
--- a/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
+++ b/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
@@ -116,7 +116,7 @@ public abstract class InstanceKeyDataSource implements DataSource, Referenceable
private boolean defaultLifo = BaseObjectPoolConfig.DEFAULT_LIFO;
private int defaultMaxIdle = GenericKeyedObjectPoolConfig.DEFAULT_MAX_IDLE_PER_KEY;
private int defaultMaxTotal = GenericKeyedObjectPoolConfig.DEFAULT_MAX_TOTAL;
- private long defaultMaxWaitMillis = BaseObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS;
+ private Duration defaultMaxWaitDuration = BaseObjectPoolConfig.DEFAULT_MAX_WAIT;
private long defaultMinEvictableIdleTimeMillis = BaseObjectPoolConfig.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS;
private int defaultMinIdle = GenericKeyedObjectPoolConfig.DEFAULT_MIN_IDLE_PER_KEY;
private int defaultNumTestsPerEvictionRun = BaseObjectPoolConfig.DEFAULT_NUM_TESTS_PER_EVICTION_RUN;
@@ -293,9 +293,21 @@ public abstract class InstanceKeyDataSource implements DataSource, Referenceable
* Gets the default value for {@link GenericKeyedObjectPoolConfig#getMaxWaitMillis()} for each per user pool.
*
* @return The default value for {@link GenericKeyedObjectPoolConfig#getMaxWaitMillis()} for each per user pool.
+ * @since 2.9.0
*/
+ public Duration getDefaultMaxWait() {
+ return this.defaultMaxWaitDuration;
+ }
+
+ /**
+ * Gets the default value for {@link GenericKeyedObjectPoolConfig#getMaxWaitMillis()} for each per user pool.
+ *
+ * @return The default value for {@link GenericKeyedObjectPoolConfig#getMaxWaitMillis()} for each per user pool.
+ * @deprecated Use {@link #getDefaultMaxWait()}.
+ */
+ @Deprecated
public long getDefaultMaxWaitMillis() {
- return this.defaultMaxWaitMillis;
+ return getDefaultMaxWait().toMillis();
}
/**
@@ -303,17 +315,30 @@ public abstract class InstanceKeyDataSource implements DataSource, Referenceable
*
* @param maxWaitMillis
* The default value for {@link GenericKeyedObjectPoolConfig#getMaxWaitMillis()} for each per user pool.
+ * @since 2.9.0
*/
- public void setDefaultMaxWaitMillis(final long maxWaitMillis) {
+ public void setDefaultMaxWait(final Duration maxWaitMillis) {
assertInitializationAllowed();
- this.defaultMaxWaitMillis = maxWaitMillis;
+ this.defaultMaxWaitDuration = maxWaitMillis;
+ }
+
+ /**
+ * Sets the default value for {@link GenericKeyedObjectPoolConfig#getMaxWaitMillis()} for each per user pool.
+ *
+ * @param maxWaitMillis
+ * The default value for {@link GenericKeyedObjectPoolConfig#getMaxWaitMillis()} for each per user pool.
+ * @deprecated Use {@link #setDefaultMaxWait(Duration)}.
+ */
+ @Deprecated
+ public void setDefaultMaxWaitMillis(final long maxWaitMillis) {
+ setDefaultMaxWait(Duration.ofMillis(maxWaitMillis));
}
/**
- * Gets the default value for {@link GenericKeyedObjectPoolConfig#getMinEvictableIdleTimeMillis()} for each per user
+ * Gets the default value for {@link GenericKeyedObjectPoolConfig#getMinEvictableIdleTime()} for each per user
* pool.
*
- * @return The default value for {@link GenericKeyedObjectPoolConfig#getMinEvictableIdleTimeMillis()} for each per
+ * @return The default value for {@link GenericKeyedObjectPoolConfig#getMinEvictableIdleTime()} for each per
* user pool.
*/
public long getDefaultMinEvictableIdleTimeMillis() {
@@ -321,11 +346,11 @@ public abstract class InstanceKeyDataSource implements DataSource, Referenceable
}
/**
- * Sets the default value for {@link GenericKeyedObjectPoolConfig#getMinEvictableIdleTimeMillis()} for each per user
+ * Sets the default value for {@link GenericKeyedObjectPoolConfig#getMinEvictableIdleTime()} for each per user
* pool.
*
* @param minEvictableIdleTimeMillis
- * The default value for {@link GenericKeyedObjectPoolConfig#getMinEvictableIdleTimeMillis()} for each
+ * The default value for {@link GenericKeyedObjectPoolConfig#getMinEvictableIdleTime()} for each
* per user pool.
*/
public void setDefaultMinEvictableIdleTimeMillis(final long minEvictableIdleTimeMillis) {
@@ -1113,8 +1138,8 @@ public abstract class InstanceKeyDataSource implements DataSource, Referenceable
builder.append(defaultMaxIdle);
builder.append(", defaultMaxTotal=");
builder.append(defaultMaxTotal);
- builder.append(", defaultMaxWaitMillis=");
- builder.append(defaultMaxWaitMillis);
+ builder.append(", defaultMaxWait=");
+ builder.append(defaultMaxWaitDuration);
builder.append(", defaultMinEvictableIdleTimeMillis=");
builder.append(defaultMinEvictableIdleTimeMillis);
builder.append(", defaultMinIdle=");
diff --git a/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java b/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java
index f2779fb..b469f86 100644
--- a/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java
+++ b/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java
@@ -346,7 +346,7 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
}
/**
- * Gets the user specific value for {@link GenericObjectPool#getMinEvictableIdleTimeMillis()} for the specified
+ * Gets the user specific value for {@link GenericObjectPool#getMinEvictableIdleTime()} for the specified
* user's pool or the default if no user specific value is defined.
*
* @param userName
@@ -403,7 +403,7 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
}
/**
- * Gets the user specific value for {@link GenericObjectPool#getSoftMinEvictableIdleTimeMillis()} for the specified
+ * Gets the user specific value for {@link GenericObjectPool#getSoftMinEvictableIdleTime()} for the specified
* user's pool or the default if no user specific value is defined.
*
* @param userName
@@ -498,7 +498,7 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
}
/**
- * Gets the user specific value for {@link GenericObjectPool#getTimeBetweenEvictionRunsMillis()} for the specified
+ * Gets the user specific value for {@link GenericObjectPool#getTimeBetweenEvictionRuns()} for the specified
* user's pool or the default if no user specific value is defined.
*
* @param userName
@@ -908,7 +908,7 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
}
/**
- * Sets a user specific value for {@link GenericObjectPool#getMinEvictableIdleTimeMillis()} for the specified user's
+ * Sets a user specific value for {@link GenericObjectPool#getMinEvictableIdleTime()} for the specified user's
* pool.
*
* @param userName
@@ -988,7 +988,7 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
}
/**
- * Sets a user specific value for {@link GenericObjectPool#getSoftMinEvictableIdleTimeMillis()} for the specified
+ * Sets a user specific value for {@link GenericObjectPool#getSoftMinEvictableIdleTime()} for the specified
* user's pool.
*
* @param userName
@@ -1119,7 +1119,7 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
}
/**
- * Sets a user specific value for {@link GenericObjectPool#getTimeBetweenEvictionRunsMillis ()} for the specified
+ * Sets a user specific value for {@link GenericObjectPool#getTimeBetweenEvictionRuns()} for the specified
* user's pool.
*
* @param userName
diff --git a/src/main/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java b/src/main/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java
index e735c98..de3f1b0 100644
--- a/src/main/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java
+++ b/src/main/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java
@@ -169,7 +169,7 @@ public class SharedPoolDataSource extends InstanceKeyDataSource {
config.setMaxIdlePerKey(getDefaultMaxIdle());
config.setMaxTotal(getMaxTotal());
config.setMaxTotalPerKey(getDefaultMaxTotal());
- config.setMaxWaitMillis(getDefaultMaxWaitMillis());
+ config.setMaxWaitMillis(getDefaultMaxWait().toMillis());
config.setMinEvictableIdleTimeMillis(getDefaultMinEvictableIdleTimeMillis());
config.setMinIdlePerKey(getDefaultMinIdle());
config.setNumTestsPerEvictionRun(getDefaultNumTestsPerEvictionRun());