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
The following commit(s) were added to refs/heads/master by this push: new 0a71e359 Javadoc 0a71e359 is described below commit 0a71e359f37efa927f6ee1e17c0ab42eed934ad9 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Fri Jan 20 09:32:14 2023 -0500 Javadoc Only assign local once --- .../java/org/apache/commons/dbcp2/DelegatingConnection.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java b/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java index 0b14076c..1f5ed748 100644 --- a/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java +++ b/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java @@ -41,6 +41,8 @@ import java.util.Map; import java.util.Properties; import java.util.concurrent.Executor; +import org.apache.commons.dbcp2.managed.ManagedConnection; + /** * A base delegating implementation of {@link Connection}. * <p> @@ -78,7 +80,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace i /** * Creates a wrapper for the Connection which traces this Connection in the AbandonedObjectPool. * - * @param connection the {@link Connection} to delegate all calls to. + * @param connection the {@link Connection} to delegate all calls to, may be null (see {@link ManagedConnection}). */ public DelegatingConnection(final C connection) { this.connection = connection; @@ -104,11 +106,12 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace i protected void checkOpen() throws SQLException { if (closed) { if (null != connection) { - String label = ""; + String label; try { label = connection.toString(); - } catch (final Exception ignored) { - // ignore, leave label empty + } catch (final Exception e) { + // leave label empty + label = ""; } throw new SQLException("Connection " + label + " is closed."); } @@ -903,7 +906,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace i * Sets my delegate. * * @param connection - * my delegate. + * my delegate, may be null. */ public void setDelegate(final C connection) { this.connection = connection;