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

markt-asf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 55c2a82dcc Align unwrap and isWrapperFor
55c2a82dcc is described below

commit 55c2a82dcc860f6a4c0f31b800b466107af4a903
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Jun 2 11:24:53 2026 +0100

    Align unwrap and isWrapperFor
---
 java/org/apache/naming/factory/DataSourceLinkFactory.java | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/naming/factory/DataSourceLinkFactory.java 
b/java/org/apache/naming/factory/DataSourceLinkFactory.java
index 966d2368e7..ac36cba598 100644
--- a/java/org/apache/naming/factory/DataSourceLinkFactory.java
+++ b/java/org/apache/naming/factory/DataSourceLinkFactory.java
@@ -144,7 +144,10 @@ public class DataSourceLinkFactory extends 
ResourceLinkFactory {
                 return unwrap((Class<?>) args[0]);
             } else if ("isWrapperFor".equals(method.getName())) {
                 Class<?> iface = (Class<?>) args[0];
-                return iface != null && iface.isInstance(ds);
+                if (iface != null && iface.isInstance(ds)) {
+                    return Boolean.TRUE;
+                }
+                // If not, delegate to the wrapped resource
             }
 
             try {
@@ -166,15 +169,12 @@ public class DataSourceLinkFactory extends 
ResourceLinkFactory {
          * @throws SQLException if the interface does not match DataSource
          */
         public Object unwrap(Class<?> iface) throws SQLException {
-            if (iface == DataSource.class) {
+            if (iface == DataSource.class || iface.isInstance(ds)) {
                 return ds;
             } else {
-                throw new 
SQLException(sm.getString("dataSourceLinkFactory.badWrapper", iface.getName()));
+                return ds.unwrap(iface);
             }
         }
-
     }
-
-
 }
 


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

Reply via email to