You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add close() method to LazyConnectionDataSourceProxy [SPR-11571] #16195
It would be a convenient feature if the LazyConnectionDataSourceProxy would provide a public close() method that delegates to a (possibly configurable) destroy-method on the wrapped DataSource if one is present. This would avoid having to declare two datasource beans: one for the LazyConnectionDataSourceProxy and one for the underlying DataSource itself, so that the proper destroy-method can be called on it.
I'm initializing my DataSource as follows:
@BeanpublicDataSourcedataSource() {
PGSimpleDataSourcedataSource = newPGSimpleDataSource();
// set properties ...// set up connection pool, HikariCP in my caseHikariDataSourceconnectionPool = newHikariDataSource(config);
LazyConnectionDataSourceProxylazyDataSource = newLazyConnectionDataSourceProxy();
lazyDataSource.setTargetDataSource(connectionPool);
// set properties ...returnlazyDataSource;
}
A suggestion how this could work would be:
@Bean(destroyMethod="close") // as per defaultpublicDataSourcedataSource() {
PGSimpleDataSourcedataSource = newPGSimpleDataSource();
// set properties ...// set up connection pool, HikariCP in my caseHikariDataSourceconnectionPool = newHikariDataSource(config);
LazyConnectionDataSourceProxylazyDataSource = newLazyConnectionDataSourceProxy();
lazyDataSource.setTargetDataSource(connectionPool);
// set properties ...lazyDataSource.setDestroyMethod("shutdown"); // or call "close" by defaultreturnlazyDataSource;
}
Activity
spring-projects-issues commentedon Jul 6, 2015
Scott Feldstein commented
I worked around this issue by instantiating my dataSource Bean as follows:
spring-projects-issues commentedon Jan 12, 2019
Bulk closing outdated, unresolved issues. Please, reopen if still relevant.