|
[
Permlink
| « Hide
]
Phil Steitz added a comment - 11/May/07 04:57 AM
Behavior here is determined by the underlying pool. In the case of commons pool's GenericObjectPool, which BasicDataSource uses, the close method only closes idle connections in the pool. The BasicDataSource Javadoc should be improved to make it clear that only idle connections are closed when close is invoked on the BasicDataSource.
BasicDataSource.close() now permanently marks the data source as closed. No new connections can be obtained from a closed data source. At close all idle connections are destroyed and the method returns. As existing active connections are closed, they are destroyed.
I agree with the change of behaviour of close() so that its permanently closed.
However we relied on the current behaviour as a way of restarting the Connection Pool after changing its properties without a full JVM restart. (e.g. change the Database URL). I agree this is a hack and there is no guarantee it will continue to work. But I think you might agree, is a useful feature to have. Looking at the source code, I spotted a restart() method which is currently private and not used, which just calls close(). Will it make sense to expose this method and have an overloaded method close(boolean permanent) which controls if its a permanent close or not. If you agree, I am happy to submit a patch. The problem with supporting restart is that you either have to force close the connections that are checked out to clients (not generally a happy scenario) or you no longer have a uniform pool of connections. Deciding how to handle the latter problem from the pool's perspective is probably what stalled the implementation of "restart". If you have ideas about how to implement this without adding too much complexity for the user or dbcp iteslf, we should discuss them on the dev list.
|
||||||||||||||||||||||||||||||||||||||||||||||||||