This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 747865894d Improve handling of get[Pooled]Connection(String,String)
747865894d is described below
commit 747865894d5c8df8456847200ac246476b65846f
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 aa03553df5..3bf1db40d2 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -204,6 +204,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 9.0.121 (remm)" rtext="release in progress">
<subsection name="Catalina">
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.