You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by eb...@apache.org on 2020/12/04 13:15:50 UTC
[commons-dbcp] 05/09: Collapse identical catch blocks
This is an automated email from the ASF dual-hosted git repository.
ebourg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-dbcp.git
commit 7fb272a93f1331eb312f994acfb5a66053a2c7b7
Author: Emmanuel Bourg <eb...@apache.org>
AuthorDate: Fri Dec 4 13:36:33 2020 +0100
Collapse identical catch blocks
---
.../org/apache/commons/dbcp2/PoolableCallableStatement.java | 4 +---
src/main/java/org/apache/commons/dbcp2/PoolableConnection.java | 4 +---
.../org/apache/commons/dbcp2/PoolablePreparedStatement.java | 4 +---
src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java | 4 +---
src/main/java/org/apache/commons/dbcp2/PoolingDriver.java | 4 +---
.../commons/dbcp2/datasources/InstanceKeyDataSource.java | 10 ++--------
6 files changed, 7 insertions(+), 23 deletions(-)
diff --git a/src/main/java/org/apache/commons/dbcp2/PoolableCallableStatement.java b/src/main/java/org/apache/commons/dbcp2/PoolableCallableStatement.java
index da7e6fe..d9e765d 100644
--- a/src/main/java/org/apache/commons/dbcp2/PoolableCallableStatement.java
+++ b/src/main/java/org/apache/commons/dbcp2/PoolableCallableStatement.java
@@ -80,9 +80,7 @@ public class PoolableCallableStatement extends DelegatingCallableStatement {
if (!isClosed()) {
try {
pool.returnObject(key, this);
- } catch (final SQLException e) {
- throw e;
- } catch (final RuntimeException e) {
+ } catch (final SQLException | RuntimeException e) {
throw e;
} catch (final Exception e) {
throw new SQLException("Cannot close CallableStatement (return to pool failed)", e);
diff --git a/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java b/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
index 4365a21..0cd0ee0 100644
--- a/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
+++ b/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
@@ -205,9 +205,7 @@ public class PoolableConnection extends DelegatingConnection<Connection> impleme
// pool is closed, so close the connection
passivate();
getInnermostDelegate().close();
- } catch (final SQLException e) {
- throw e;
- } catch (final RuntimeException e) {
+ } catch (final SQLException | RuntimeException e) {
throw e;
} catch (final Exception e) {
throw new SQLException("Cannot close connection (return to pool failed)", e);
diff --git a/src/main/java/org/apache/commons/dbcp2/PoolablePreparedStatement.java b/src/main/java/org/apache/commons/dbcp2/PoolablePreparedStatement.java
index 382c56f..a2f11a3 100644
--- a/src/main/java/org/apache/commons/dbcp2/PoolablePreparedStatement.java
+++ b/src/main/java/org/apache/commons/dbcp2/PoolablePreparedStatement.java
@@ -102,9 +102,7 @@ public class PoolablePreparedStatement<K> extends DelegatingPreparedStatement {
if (!isClosed()) {
try {
pool.returnObject(key, this);
- } catch (final SQLException e) {
- throw e;
- } catch (final RuntimeException e) {
+ } catch (final SQLException | RuntimeException e) {
throw e;
} catch (final Exception e) {
throw new SQLException("Cannot close preparedstatement (return to pool failed)", e);
diff --git a/src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java b/src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java
index fc1965c..0169d9b 100644
--- a/src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java
+++ b/src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java
@@ -136,11 +136,9 @@ public class PoolingDataSource<C extends Connection> implements DataSource, Auto
return null;
}
return new PoolGuardConnectionWrapper<>(conn);
- } catch (final SQLException e) {
- throw e;
} catch (final NoSuchElementException e) {
throw new SQLException("Cannot get a connection, pool error " + e.getMessage(), e);
- } catch (final RuntimeException e) {
+ } catch (final SQLException | RuntimeException e) {
throw e;
} catch (final InterruptedException e) {
// Reset the interrupt status so it is visible to callers
diff --git a/src/main/java/org/apache/commons/dbcp2/PoolingDriver.java b/src/main/java/org/apache/commons/dbcp2/PoolingDriver.java
index 5ba3664..f531859 100644
--- a/src/main/java/org/apache/commons/dbcp2/PoolingDriver.java
+++ b/src/main/java/org/apache/commons/dbcp2/PoolingDriver.java
@@ -154,11 +154,9 @@ public class PoolingDriver implements Driver {
return null;
}
return new PoolGuardConnectionWrapper(pool, conn);
- } catch (final SQLException e) {
- throw e;
} catch (final NoSuchElementException e) {
throw new SQLException("Cannot get a connection, pool error: " + e.getMessage(), e);
- } catch (final RuntimeException e) {
+ } catch (final SQLException | RuntimeException e) {
throw e;
} catch (final Exception e) {
throw new SQLException("Cannot get a connection, general error: " + e.getMessage(), e);
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 1605d7c..96ab52b 100644
--- a/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
+++ b/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
@@ -916,10 +916,7 @@ public abstract class InstanceKeyDataSource implements DataSource, Referenceable
} catch (final NoSuchElementException e) {
closeDueToException(info);
throw new SQLException("Cannot borrow connection from pool", e);
- } catch (final RuntimeException e) {
- closeDueToException(info);
- throw e;
- } catch (final SQLException e) {
+ } catch (final RuntimeException | SQLException e) {
closeDueToException(info);
throw e;
} catch (final Exception e) {
@@ -956,10 +953,7 @@ public abstract class InstanceKeyDataSource implements DataSource, Referenceable
} catch (final NoSuchElementException e) {
closeDueToException(info);
throw new SQLException("Cannot borrow connection from pool", e);
- } catch (final RuntimeException e) {
- closeDueToException(info);
- throw e;
- } catch (final SQLException e) {
+ } catch (final RuntimeException | SQLException e) {
closeDueToException(info);
throw e;
} catch (final Exception e) {