This is an automated email from the ASF dual-hosted git repository.
mridulpathak pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push:
new 1033ecbc26 Replace deprecated DBCP pool Millis methods with the
Duration API
1033ecbc26 is described below
commit 1033ecbc26bdfd37f67b0277b2fe7df4150579f4
Author: Mridul Pathak <[email protected]>
AuthorDate: Mon Oct 26 21:15:16 2026 +0530
Replace deprecated DBCP pool Millis methods with the Duration API
Configure the connection pool and read its settings for the pool status
page through the commons-pool2 Duration methods, with the same values as
before, and drop the two @SuppressWarnings("deprecation") annotations that hid
the deprecated calls.
---
.../apache/ofbiz/entity/connection/DBCPConnectionFactory.java | 10 +++++-----
.../apache/ofbiz/entity/connection/DebugManagedDataSource.java | 5 ++---
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git
a/framework/entity/src/main/java/org/apache/ofbiz/entity/connection/DBCPConnectionFactory.java
b/framework/entity/src/main/java/org/apache/ofbiz/entity/connection/DBCPConnectionFactory.java
index 902a0e2159..a257e7bea0 100644
---
a/framework/entity/src/main/java/org/apache/ofbiz/entity/connection/DBCPConnectionFactory.java
+++
b/framework/entity/src/main/java/org/apache/ofbiz/entity/connection/DBCPConnectionFactory.java
@@ -21,6 +21,7 @@ package org.apache.ofbiz.entity.connection;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.SQLException;
+import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -61,7 +62,6 @@ public class DBCPConnectionFactory implements
ConnectionFactory {
// set by closeAll() when OFBiz shuts down, so that no new pool gets
created afterwards (see OFBIZ-13686)
private static volatile boolean closed = false;
- @SuppressWarnings("deprecation")
@Override
public Connection getConnection(GenericHelperInfo helperInfo, JdbcElement
abstractJdbc) throws SQLException, GenericEntityException {
if (closed) {
@@ -141,13 +141,13 @@ public class DBCPConnectionFactory implements
ConnectionFactory {
// settings for idle connections
poolConfig.setMaxIdle(maxIdle);
poolConfig.setMinIdle(minSize);
-
poolConfig.setTimeBetweenEvictionRunsMillis(jdbcElement.getTimeBetweenEvictionRunsMillis());
- poolConfig.setMinEvictableIdleTimeMillis(-1); // disabled in favour of
setSoftMinEvictableIdleTimeMillis(...)
-
poolConfig.setSoftMinEvictableIdleTimeMillis(jdbcElement.getSoftMinEvictableIdleTimeMillis());
+
poolConfig.setTimeBetweenEvictionRuns(Duration.ofMillis(jdbcElement.getTimeBetweenEvictionRunsMillis()));
+ poolConfig.setMinEvictableIdleDuration(Duration.ofMillis(-1)); //
disabled in favour of setSoftMinEvictableIdleDuration(...)
+
poolConfig.setSoftMinEvictableIdleDuration(Duration.ofMillis(jdbcElement.getSoftMinEvictableIdleTimeMillis()));
poolConfig.setNumTestsPerEvictionRun(maxSize); // test all the idle
connections
// settings for when the pool is exhausted
poolConfig.setBlockWhenExhausted(true); // the thread requesting the
connection waits if no connection is available
- poolConfig.setMaxWaitMillis(jdbcElement.getPoolSleeptime()); // throw
an exception if, after getPoolSleeptime() ms,
+
poolConfig.setMaxWait(Duration.ofMillis(jdbcElement.getPoolSleeptime())); //
throw an exception if, after getPoolSleeptime() ms,
// no connection is available for the requesting thread
// settings for the execution of the validation query
poolConfig.setTestOnCreate(jdbcElement.getTestOnCreate());
diff --git
a/framework/entity/src/main/java/org/apache/ofbiz/entity/connection/DebugManagedDataSource.java
b/framework/entity/src/main/java/org/apache/ofbiz/entity/connection/DebugManagedDataSource.java
index f0339a82ee..b3e75df175 100644
---
a/framework/entity/src/main/java/org/apache/ofbiz/entity/connection/DebugManagedDataSource.java
+++
b/framework/entity/src/main/java/org/apache/ofbiz/entity/connection/DebugManagedDataSource.java
@@ -61,7 +61,6 @@ public class DebugManagedDataSource<C extends Connection>
extends ManagedDataSou
* Gets info.
* @return the info
*/
- @SuppressWarnings("deprecation")
public Map<String, Object> getInfo() {
Map<String, Object> dataSourceInfo = new HashMap<>();
dataSourceInfo.put("poolNumActive", super.getPool().getNumActive());
@@ -71,8 +70,8 @@ public class DebugManagedDataSource<C extends Connection>
extends ManagedDataSou
GenericObjectPool<?> objectPool = (GenericObjectPool<?>)
super.getPool();
dataSourceInfo.put("poolMaxActive", objectPool.getMaxTotal());
dataSourceInfo.put("poolMaxIdle", objectPool.getMaxIdle());
- dataSourceInfo.put("poolMaxWait", objectPool.getMaxWaitMillis());
- dataSourceInfo.put("poolMinEvictableIdleTimeMillis",
objectPool.getMinEvictableIdleTimeMillis());
+ dataSourceInfo.put("poolMaxWait",
objectPool.getMaxWaitDuration().toMillis());
+ dataSourceInfo.put("poolMinEvictableIdleTimeMillis",
objectPool.getMinEvictableIdleDuration().toMillis());
dataSourceInfo.put("poolMinIdle", objectPool.getMinIdle());
}
return dataSourceInfo;