Skip to content

AbstractRoutingDataSource does not allow to unwrap the underlying datasource [SPR-9856] #14489

@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits 9ff640a, da8e2d6

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions