swaldman / c3p0

a mature, highly concurrent JDBC Connection pooling library, with support for caching and reuse of PreparedStatements.
http://www.mchange.com/projects/c3p0
Other
1.28k stars 338 forks source link

ComboPooledDataSource not implementing java.io.Closeable #131

Closed koszta5 closed 6 months ago

koszta5 commented 5 years ago

ComboPooledDataSource does not implement this common interface. Is there any specific reason for that?

I understand keeping support for JDK6 not implementing AutoCloseable but closeable has been around since forever.

This really bit me badly with connection leaks. Also e.g. Springframework calls close() on all Closeable objects beans when context is shutting down

swaldman commented 6 months ago

I think I thought java.io.Closeable maybe not so appropriate because of the java.io package and throws IOException. I'd considered in the 0.9.5.x series adding AutoCloseable, but ultimately left a note to defer that to the next release. So we'll add that to 0.10.0.

AutoCloseable is a Java 7 innovation, so adding that will necessitate targeting Java 7 rather than Java 6 classfiles. I think that's okay at this point. For legacy applications that really don't want to update past Java 6, the 0.9.5.x series still works, I hope what I'm up to now amounts to something of an improvement but there's little absolutely critical.

Thanks!

See https://github.com/swaldman/c3p0/commit/a3906341a86c610327aa95c9429e82529ebca9c4

See