This is an automated email from the ASF dual-hosted git repository.

rmaucher pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit b2879e07bf327a63a022917038a0bc0114c55f00
Author: opencode <[email protected]>
AuthorDate: Thu Nov 5 17:18:03 2026 +0100

    Warn about credential write-back on the pool MBean
    
    The Url and ConnectionProperties attributes mask inline credentials on read 
but accept the whole raw string on write. Document that the masked value is not 
safe to write back and point at setPassword/setUsername and getPool() for the 
raw value. Also document the live-name versus fixed-registration-name split, 
the notification source fallback label, and the null ObjectName after a refused 
registration.
---
 .../tomcat/jdbc/pool/jmx/ConnectionPool.java       | 33 ++++++++++++++++++++--
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git 
a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java
 
b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java
index 3e11f13a5d..cd4c22c2af 100644
--- 
a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java
+++ 
b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java
@@ -43,6 +43,10 @@ import org.apache.tomcat.jdbc.pool.util.MessageFactory;
 /**
  * JMX MBean wrapper for a {@link org.apache.tomcat.jdbc.pool.ConnectionPool}. 
Provides management and monitoring
  * capabilities for connection pool statistics, operations, and configuration.
+ * <p>
+ * The ObjectName this MBean is registered under is fixed when the 
registration succeeds. A refused registration leaves
+ * {@link #getObjectName()} null until a later registration succeeds; {@link 
#getName()} and {@link #getPoolName()}
+ * report the pool's live name and may differ from that registration name 
after a rename.
  */
 public class ConnectionPool extends NotificationBroadcasterSupport implements 
ConnectionPoolMBean, MBeanRegistration {
 
@@ -339,7 +343,8 @@ public class ConnectionPool extends 
NotificationBroadcasterSupport implements Co
      * that has never been registered, or one the server has taken back while 
its pool keeps running - has no such
      * name: the source is then a string that names the pool.
      *
-     * @return the registered ObjectName, or a string naming the pool if the 
MBean is not registered
+     * @return the registered ObjectName, or a string naming the pool if the 
MBean is not registered. That fallback is
+     *             a diagnostic label, not necessarily a valid ObjectName
      */
     protected Object getNotificationSource() {
         // The registration handle is written by whichever thread registers or
@@ -464,7 +469,12 @@ public class ConnectionPool extends 
NotificationBroadcasterSupport implements Co
      * Returns the connection properties with any credential they carry masked 
out, so that a read of this attribute
      * does not hand back in cleartext the password {@link #getPassword()} 
exists to withhold. The write is not masked:
      * {@link #setConnectionProperties(String)} takes the string as it is 
meant to reach the driver, which is the same
-     * read/write asymmetry the password attribute has. {@inheritDoc}
+     * read/write asymmetry the password attribute has.
+     * <p>
+     * The masked value is a display value, not a safe value to write back: 
the ordinary read-modify-write replaces the
+     * credential with the mask and leaves the pool unable to authenticate. 
Change the credential through
+     * {@link #setPassword(String)} and {@link #setUsername(String)}, or read 
the raw value from {@link #getPool()}.
+     * {@inheritDoc}
      */
     @Override
     public String getConnectionProperties() {
@@ -566,6 +576,12 @@ public class ConnectionPool extends 
NotificationBroadcasterSupport implements Co
         return getPoolProperties().getMaxAge();
     }
 
+    /**
+     * Returns the pool's current name, as the {@code Name} attribute. This is 
the live configuration value and may
+     * differ from the ObjectName this MBean was registered under after a 
rename; see {@link #setName(String)}.
+     *
+     * @return the pool's current name
+     */
     @Override
     public String getName() {
         return this.getPoolName();
@@ -599,7 +615,12 @@ public class ConnectionPool extends 
NotificationBroadcasterSupport implements Co
      * Returns the JDBC URL with any credential it carries masked out, so that 
a read of this attribute does not hand
      * back in cleartext the password {@link #getPassword()} exists to 
withhold. The write is not masked:
      * {@link #setUrl(String)} takes the URL as it is meant to reach the 
driver, which is the same read/write asymmetry
-     * the password attribute has. {@inheritDoc}
+     * the password attribute has.
+     * <p>
+     * The masked value is a display value, not a safe value to write back: 
the ordinary read-modify-write replaces the
+     * credential with the mask and leaves the pool unable to authenticate. 
Change the credential through
+     * {@link #setPassword(String)} and {@link #setUsername(String)}, or read 
the raw value from {@link #getPool()}.
+     * {@inheritDoc}
      */
     @Override
     public String getUrl() {
@@ -803,6 +824,12 @@ public class ConnectionPool extends 
NotificationBroadcasterSupport implements Co
         getPoolProperties().setName(name);
     }
 
+    /**
+     * Returns the pool's current name, as the {@code PoolName} attribute. The 
MBean's registration name is fixed when
+     * it is registered; a rename changes this value without moving the 
registration.
+     *
+     * @return the pool's current name
+     */
     @Override
     public String getPoolName() {
         return getPoolProperties().getName();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to