-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Labels
in: dataIssues in data modules (jdbc, orm, oxm, tx)Issues in data modules (jdbc, orm, oxm, tx)type: bugA general bugA general bug
Milestone
Description
Juan M. Tula opened SPR-9770 and commented
Status Quo
Spring's DelegatingDataSource
does not correctly implement the java.sql.Wrapper
interface.
Analysis
According to the documentation for the unwrap()
and isWrapper()
methods, if the receiver implements the received interface, it should return itself, something like this:
public <T> T unwrap(Class<T> iface) throws SQLException {
T result;
if(iface.isInstance(this)) {
result = iface.cast(this);
} else {
result = getTargetDataSource().unwrap(iface);
}
return result;
}
But the implementation is currently this:
public <T> T unwrap(Class<T> iface) throws SQLException {
return getTargetDataSource().unwrap(iface);
}
So, a call to new DelegatingDataSource().unwrap(DelegatingDataSource.class)
will fail instead of returning itself.
Affects: 3.1 GA
Reference URL: http://docs.oracle.com/javase/6/docs/api/java/sql/Wrapper.html?is-external=true
Issue Links:
- AbstractRoutingDataSource does not allow to unwrap the underlying datasource [SPR-9856] #14489 AbstractRoutingDataSource does not allow to unwrap the underlying datasource
0 votes, 6 watchers
Metadata
Metadata
Assignees
Labels
in: dataIssues in data modules (jdbc, orm, oxm, tx)Issues in data modules (jdbc, orm, oxm, tx)type: bugA general bugA general bug