-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Description
Hernan J. Gonzalez opened SPR-9856 and commented
#14404 fixed a faulty implementation of java.sql.Wrapper
in DelegatingDataSource
.
Now, AbstractRoutingDataSource
does not override isWrapper()
unwrap()
methods. I think it should override them, so that the isInstance()
matching is done, not with respect to the class itself (perhaps also with the class itself?) but also with the currently routed datasource.
Case in point: I have a RoutingDataSource
than can either route to a org.apache.commons.dbcp.BasicDataSource
pool or a plain jdbc datasource. I wanted to call myRoutingDataSource.isWrapperFor(org.apache.commons.dbcp.BasicDataSource.class)
to check I'm using the pooled data source, and call unwrap()
to retrieve the wrapped dbcp object (for debugging purposes). Currently, I have no way of doing that, AFAIK.
As an alternative, if this is not deemed correct for the semantics of java.sql.Wrapper
(it might be debatable if the Wrapper interface was intented to have a inmutable behaviour, i'd say no), a public accesor to the underlying datasource should be provided.
Affects: 3.1 GA
Issue Links:
- DelegatingDataSource incorrectly implements java.sql.Wrapper [SPR-9770] #14404 DelegatingDataSource incorrectly implements java.sql.Wrapper