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 a89accafa2 Align unwrap and isWrapperFor
a89accafa2 is described below
commit a89accafa2cc500535a932b490942d55905cec4f
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]