This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new 57f98a1ff2 Align unwrap and isWrapperFor
57f98a1ff2 is described below
commit 57f98a1ff2ff2a659b074cf2512de4d3ea7af3cd
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 6568885468..d4f69dac73 100644
--- a/java/org/apache/naming/factory/DataSourceLinkFactory.java
+++ b/java/org/apache/naming/factory/DataSourceLinkFactory.java
@@ -147,7 +147,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 {
@@ -169,15 +172,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]