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 2018/11/14 15:23:13 UTC
commons-dbcp git commit: Add
org.apache.commons.dbcp2.Utils.closeQuietly(AutoCloseable) and deprecate: -
org.apache.commons.dbcp2.Utils.closeQuietly(Connection) -
org.apache.commons.dbcp2.Utils.closeQuietly(ResultSet) -
org.apache.commons.dbcp2.Utils.clo
Repository: commons-dbcp
Updated Branches:
refs/heads/master d139c4d21 -> 11a7aff1b
Add org.apache.commons.dbcp2.Utils.closeQuietly(AutoCloseable) and
deprecate:
- org.apache.commons.dbcp2.Utils.closeQuietly(Connection)
- org.apache.commons.dbcp2.Utils.closeQuietly(ResultSet)
- org.apache.commons.dbcp2.Utils.closeQuietly(Statement)
Project: http://git-wip-us.apache.org/repos/asf/commons-dbcp/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbcp/commit/11a7aff1
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbcp/tree/11a7aff1
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbcp/diff/11a7aff1
Branch: refs/heads/master
Commit: 11a7aff1b5c38a9cdf056714a20c8c7478925c08
Parents: d139c4d
Author: Gary Gregory <ga...@gmail.com>
Authored: Wed Nov 14 08:23:10 2018 -0700
Committer: Gary Gregory <ga...@gmail.com>
Committed: Wed Nov 14 08:23:10 2018 -0700
----------------------------------------------------------------------
.../java/org/apache/commons/dbcp2/Utils.java | 42 +++++++++++++++-----
1 file changed, 32 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/11a7aff1/src/main/java/org/apache/commons/dbcp2/Utils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbcp2/Utils.java b/src/main/java/org/apache/commons/dbcp2/Utils.java
index 4cd37b3..4659841 100644
--- a/src/main/java/org/apache/commons/dbcp2/Utils.java
+++ b/src/main/java/org/apache/commons/dbcp2/Utils.java
@@ -67,10 +67,6 @@ public final class Utils {
DISCONNECTION_SQL_CODES.add("JZ0C1"); // Sybase disconnect error
}
- private Utils() {
- // not instantiable
- }
-
/**
* Clones the given char[] if not null.
*
@@ -83,15 +79,15 @@ public final class Utils {
}
/**
- * Closes the ResultSet (which may be null).
+ * Closes the AutoCloseable (which may be null).
*
- * @param resultSet
- * a ResultSet, may be {@code null}
+ * @param autoCloseable
+ * an AutoCloseable, may be {@code null}
*/
- public static void closeQuietly(final ResultSet resultSet) {
- if (resultSet != null) {
+ public static void closeQuietly(final AutoCloseable autoCloseable) {
+ if (autoCloseable != null) {
try {
- resultSet.close();
+ autoCloseable.close();
} catch (final Exception e) {
// ignored
}
@@ -103,7 +99,9 @@ public final class Utils {
*
* @param connection
* a Connection, may be {@code null}
+ * @deprecated Use {@link #closeQuietly(AutoCloseable)}.
*/
+ @Deprecated
public static void closeQuietly(final Connection connection) {
if (connection != null) {
try {
@@ -115,11 +113,31 @@ public final class Utils {
}
/**
+ * Closes the ResultSet (which may be null).
+ *
+ * @param resultSet
+ * a ResultSet, may be {@code null}
+ * @deprecated Use {@link #closeQuietly(AutoCloseable)}.
+ */
+ @Deprecated
+ public static void closeQuietly(final ResultSet resultSet) {
+ if (resultSet != null) {
+ try {
+ resultSet.close();
+ } catch (final Exception e) {
+ // ignored
+ }
+ }
+ }
+
+ /**
* Closes the Statement (which may be null).
*
* @param statement
* a Statement, may be {@code null}.
+ * @deprecated Use {@link #closeQuietly(AutoCloseable)}.
*/
+ @Deprecated
public static void closeQuietly(final Statement statement) {
if (statement != null) {
try {
@@ -181,4 +199,8 @@ public final class Utils {
return value == null ? null : String.valueOf(value);
}
+ private Utils() {
+ // not instantiable
+ }
+
}