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

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

commit a002e754ccd6d23fa81d2e777e1cb839c7c4271d
Author: opencode <[email protected]>
AuthorDate: Thu Oct 29 22:45:54 2026 +0100

    DataSourceProxy: reject a null PoolConfiguration in the setter
    
    The constructor documents the class invariant by rejecting a null
    PoolConfiguration with NullPointerException, but setPoolProperties()
    accepted null, leaving the data source half-initialised: the
    delegating property accessors then threw bare NPEs at opaque points
    and the login-timeout accessors silently degraded to returning 0 or
    being no-ops. The setter now mirrors the constructor's check and
    message, failing fast at the misuse site with the prior configuration
    left intact.
---
 .../main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java    | 8 ++++++++
 1 file changed, 8 insertions(+)

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 862146dd12..630824d953 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
@@ -407,6 +407,14 @@ public class DataSourceProxy implements PoolConfiguration {
      * @param poolProperties The new pool configuration
      */
     public void setPoolProperties(PoolConfiguration poolProperties) {
+        // Same fail-fast check as the constructor: a null configuration would
+        // leave the ~60 delegating accessors and the borrow paths to throw
+        // bare NullPointerExceptions at opaque points, while the login timeout
+        // accessors would silently degrade. The class invariant is that this
+        // field is never null, so reject the misuse at its site.
+        if (poolProperties == null) {
+            throw new NullPointerException("PoolConfiguration cannot be 
null.");
+        }
         this.poolProperties = poolProperties;
     }
 


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

Reply via email to