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 2023/06/23 14:20:42 UTC

[commons-dbcp] branch master updated (c19da029 -> cbcac4d6)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-dbcp.git


    from c19da029 Bump actions/checkout from 3.5.2 to 3.5.3 (#280)
     new a721f0cc CPDSConnectionFactory.makeObject() does not need to wrap and rethrow SQLException.
     new cbcac4d6 PoolingDataSource.close() now always throws SQLException

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                            |  6 ++++
 .../apache/commons/dbcp2/PoolingDataSource.java    |  4 +--
 .../dbcp2/datasources/CPDSConnectionFactory.java   | 34 ++++++++++------------
 3 files changed, 22 insertions(+), 22 deletions(-)


[commons-dbcp] 02/02: PoolingDataSource.close() now always throws SQLException

Posted by gg...@apache.org.
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 cbcac4d6e59651827b29e7fb1623071665d65ad0
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jun 23 09:41:28 2023 -0400

    PoolingDataSource.close() now always throws SQLException
---
 src/changes/changes.xml                                       | 3 +++
 src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java | 4 +---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 1d8253ff..6e59379f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -121,6 +121,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="fix" due-to="Gary Gregory">
         CPDSConnectionFactory.makeObject() does not need to wrap and rethrow SQLException.
       </action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">
+        PoolingDataSource.close() now always throws SQLException.
+      </action>
       <!-- ADD -->
       <action dev="ggregory" type="add" due-to="Gary Gregory">
         Add and use AbandonedTrace#setLastUsed(Instant).
diff --git a/src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java b/src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java
index 40d2c1c2..8643b5ab 100644
--- a/src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java
+++ b/src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java
@@ -121,11 +121,9 @@ public class PoolingDataSource<C extends Connection> implements DataSource, Auto
      * @since 2.1
      */
     @Override
-    public void close() throws RuntimeException, SQLException {
+    public void close() throws SQLException {
         try {
             pool.close();
-        } catch (final RuntimeException rte) {
-            throw new RuntimeException(Utils.getMessage("pool.close.fail"), rte);
         } catch (final Exception e) {
             throw new SQLException(Utils.getMessage("pool.close.fail"), e);
         }


[commons-dbcp] 01/02: CPDSConnectionFactory.makeObject() does not need to wrap and rethrow SQLException.

Posted by gg...@apache.org.
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 a721f0cceee2528af1bff76be8fe80ab01769efa
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jun 23 09:33:43 2023 -0400

    CPDSConnectionFactory.makeObject() does not need to wrap and rethrow
    SQLException.
---
 src/changes/changes.xml                            |  3 ++
 .../dbcp2/datasources/CPDSConnectionFactory.java   | 34 ++++++++++------------
 2 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 361409d6..1d8253ff 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -118,6 +118,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="fix" due-to="Gary Gregory">
         Throw SQLException instead of NullPointerException when the connection is already closed.
       </action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">
+        CPDSConnectionFactory.makeObject() does not need to wrap and rethrow SQLException.
+      </action>
       <!-- ADD -->
       <action dev="ggregory" type="add" due-to="Gary Gregory">
         Add and use AbandonedTrace#setLastUsed(Instant).
diff --git a/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java b/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java
index 9d04001c..ce0f08ce 100644
--- a/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java
+++ b/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java
@@ -304,26 +304,22 @@ final class CPDSConnectionFactory
     }
 
     @Override
-    public synchronized PooledObject<PooledConnectionAndInfo> makeObject() {
-        try {
-            PooledConnection pc = null;
-            if (userPassKey.getUserName() == null) {
-                pc = cpds.getPooledConnection();
-            } else {
-                pc = cpds.getPooledConnection(userPassKey.getUserName(), userPassKey.getPassword());
-            }
-            if (pc == null) {
-                throw new IllegalStateException("Connection pool data source returned null from getPooledConnection");
-            }
-            // should we add this object as a listener or the pool.
-            // consider the validateObject method in decision
-            pc.addConnectionEventListener(this);
-            final PooledConnectionAndInfo pci = new PooledConnectionAndInfo(pc, userPassKey);
-            pcMap.put(pc, pci);
-            return new DefaultPooledObject<>(pci);
-        } catch (final SQLException e) {
-            throw new RuntimeException(e.getMessage());
+    public synchronized PooledObject<PooledConnectionAndInfo> makeObject() throws SQLException {
+        PooledConnection pc = null;
+        if (userPassKey.getUserName() == null) {
+            pc = cpds.getPooledConnection();
+        } else {
+            pc = cpds.getPooledConnection(userPassKey.getUserName(), userPassKey.getPassword());
+        }
+        if (pc == null) {
+            throw new IllegalStateException("Connection pool data source returned null from getPooledConnection");
         }
+        // should we add this object as a listener or the pool.
+        // consider the validateObject method in decision
+        pc.addConnectionEventListener(this);
+        final PooledConnectionAndInfo pci = new PooledConnectionAndInfo(pc, userPassKey);
+        pcMap.put(pc, pci);
+        return new DefaultPooledObject<>(pci);
     }
 
     @Override