This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new 6e42b0d2fa Improve handling of get[Pooled]Connection(String,String)
6e42b0d2fa is described below
commit 6e42b0d2fa0edf56ae8da2d01262b29153e9ad64
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Aug 26 07:30:08 2026 +0100
Improve handling of get[Pooled]Connection(String,String)
---
.../org/apache/tomcat/jdbc/pool/DataSourceProxy.java | 16 ++++++++++++----
webapps/docs/changelog.xml | 14 ++++++++++++++
2 files changed, 26 insertions(+), 4 deletions(-)
diff --git
a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
index 54b6eb33f2..f3236bd5c9 100644
---
a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
+++
b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
@@ -23,6 +23,7 @@ import java.sql.SQLFeatureNotSupportedException;
import java.util.Iterator;
import java.util.Properties;
import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Logger;
import javax.sql.XAConnection;
@@ -43,6 +44,8 @@ import
org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorDefinition;
public class DataSourceProxy implements PoolConfiguration {
private static final Log log = LogFactory.getLog(DataSourceProxy.class);
+ private final AtomicBoolean connectionWithoutCredentialsWarningIssued =
new AtomicBoolean(false);
+
/**
* The underlying connection pool.
*/
@@ -120,6 +123,11 @@ public class DataSourceProxy implements PoolConfiguration {
}
return pool.getConnection(username,password);
} else {
+ if (connectionWithoutCredentialsWarningIssued.compareAndSet(false,
true)) {
+ log.warn(String.format(
+ "alternateUsernameAllowed is set to false so the
provided user name [%s] and associated " +
+ "password have been ignored", username));
+ }
return getConnection();
}
}
@@ -238,15 +246,15 @@ public class DataSourceProxy implements PoolConfiguration
{
/**
* Get a database connection.
- * {@link javax.sql.DataSource#getConnection()}
- * @param username unused
- * @param password unused
+ * {@link javax.sql.DataSource#getConnection(String,String)}
+ * @param username The user name
+ * @param password The password
* @return the connection
* @throws SQLException Connection error
*/
public javax.sql.PooledConnection getPooledConnection(String username,
String password) throws SQLException {
- return (javax.sql.PooledConnection) getConnection();
+ return (javax.sql.PooledConnection) getConnection(username, password);
}
/**
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index ba711cf248..69c11dbdb1 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -200,6 +200,20 @@
</docs>
</changelog>
</subsection>
+ <subsection name="jdbc-pool">
+ <changelog>
+ <fix>
+ <code>DataSourceProxy.getPooledConnection(String,String)</code> now
+ delegates to <code>getConnection(String,String)</code> rather than
+ <code>getConnection()</code>. (markt)
+ </fix>
+ <add>
+ Log a warning if an attempt is made to obtain a connection with
+ credentials when <code>alternateUsernameAllowed</code> is set to
+ <code>false</code>. (markt)
+ </add>
+ </changelog>
+ </subsection>
</section>
<section name="Tomcat 11.0.25 (markt)" rtext="2026-08-18">
<subsection name="Catalina">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]