commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1735434 - in /commons/proper/dbcp/trunk/src: changes/changes.xml main/java/org/apache/commons/dbcp2/BasicDataSource.java test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java
Date Thu, 17 Mar 2016 14:30:55 GMT
Author: markt
Date: Thu Mar 17 14:30:55 2016
New Revision: 1735434

URL: http://svn.apache.org/viewvc?rev=1735434&view=rev
Log:
Fix DBCP-453
Ensure that setSoftMinEvictableIdleTimeMillis is used when working with BasicDataSource.

Modified:
    commons/proper/dbcp/trunk/src/changes/changes.xml
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java

Modified: commons/proper/dbcp/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/changes/changes.xml?rev=1735434&r1=1735433&r2=1735434&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/changes/changes.xml (original)
+++ commons/proper/dbcp/trunk/src/changes/changes.xml Thu Mar 17 14:30:55 2016
@@ -77,10 +77,14 @@ The <action> type attribute can be add,u
       <action dev="ggregory" type="add" issue="DBCP-451">
         Add constructor DriverManagerConnectionFactory(String).
       </action>
-      <action dev="markt" type="fix" issue="DBCP-455" due-to="Kyohei Nakamura ">
+      <action dev="markt" type="fix" issue="DBCP-455" due-to="Kyohei Nakamura">
         Ensure that the cacheState setting is used when statement pooling is
         disabled.
       </action>
+      <action dev="markt" type="fix" issue="DBCP-453" due-to="Philipp Marx">
+        Ensure that setSoftMinEvictableIdleTimeMillis is used when working with
+        BasicDataSource.
+      </action>
     </release>
     <release version="2.1.1" date="6 Aug 2015" description=
 "This is a patch release, including bug fixes only.">

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java?rev=1735434&r1=1735433&r2=1735434&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
Thu Mar 17 14:30:55 2016
@@ -2050,7 +2050,7 @@ public class BasicDataSource implements
             }
 
             // Create the pooling data source to manage connections
-            DataSource newDataSource; 
+            DataSource newDataSource;
             success = false;
             try {
                 newDataSource = createDataSourceInstance();
@@ -2208,6 +2208,7 @@ public class BasicDataSource implements
         gop.setTestOnReturn(testOnReturn);
         gop.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
         gop.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
+        gop.setSoftMinEvictableIdleTimeMillis(softMinEvictableIdleTimeMillis);
         gop.setTestWhileIdle(testWhileIdle);
         gop.setLifo(lifo);
         gop.setSwallowedExceptionListener(new SwallowedExceptionLogger(log, logExpiredConnections));

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java?rev=1735434&r1=1735433&r2=1735434&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java
Thu Mar 17 14:30:55 2016
@@ -32,6 +32,7 @@ import javax.management.MBeanServer;
 import javax.naming.Reference;
 import javax.naming.StringRefAddr;
 
+import org.apache.commons.pool2.impl.GenericObjectPool;
 import org.junit.Test;
 
 /**
@@ -98,6 +99,7 @@ public class TestBasicDataSourceFactory
             final BasicDataSourceFactory basicDataSourceFactory = new BasicDataSourceFactory();
             final BasicDataSource ds = (BasicDataSource) basicDataSourceFactory.getObjectInstance(ref,
null, null, null);
             checkDataSourceProperties(ds);
+            checkConnectionPoolProperties(ds.getConnectionPool());
             final List<String> messages = StackMessageLog.getAll();
             assertEquals(0,messages.size());
         } finally {
@@ -191,4 +193,24 @@ public class TestBasicDataSourceFactory
         final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
         mbs.unregisterMBean(ds.getRegisteredJmxName());
     }
+
+    private void checkConnectionPoolProperties(final GenericObjectPool<PoolableConnection>
cp) {
+        assertEquals(10, cp.getMaxTotal());
+        assertEquals(8, cp.getMaxIdle());
+        assertEquals(0, cp.getMinIdle());
+        assertEquals(500, cp.getMaxWaitMillis());
+        assertEquals(5, cp.getNumIdle());
+        assertTrue(cp.getTestOnBorrow());
+        assertFalse(cp.getTestOnReturn());
+        assertEquals(1000, cp.getTimeBetweenEvictionRunsMillis());
+        assertEquals(2000, cp.getMinEvictableIdleTimeMillis());
+        assertEquals(3000, cp.getSoftMinEvictableIdleTimeMillis());
+        assertEquals(2, cp.getNumTestsPerEvictionRun());
+        assertTrue(cp.getTestWhileIdle());
+        assertTrue(cp.getRemoveAbandonedOnBorrow());
+        assertTrue(cp.getRemoveAbandonedOnMaintenance());
+        assertEquals(3000, cp.getRemoveAbandonedTimeout());
+        assertTrue(cp.getLogAbandoned());
+        assertTrue(cp.getLifo());
+    }
 }



Mime
View raw message