Closed GoogleCodeExporter closed 9 years ago
Well, it seems that the side effect is only that 'Connection not closed' log
line,
this do not close the physical connection since close() is overriden by the
PooledJdbcConnection inner class.
So, i simply suggest to override the finalizer of the inner class
JdbcXAConnection#PooledJdbcConnection with
such kind of statement:
protected void finalize() {
if (!isClosed) {
trace.error("Pooled connection not closed");
try {
close();
} catch (SQLException e) {
trace.debug("finalize", e);
}
}
}
With the 'trace' field modifier changed from 'private' to 'protected' in
JdbcConnection class.
That workarround seems to works for me..
Original comment by ppced...@gmail.com
on 6 Jul 2009 at 2:38
Hi,
There is definetly something wrong with the finalizer in
JdbcXAConnection$PooledJdbcConnection. My test case is:
DeleteDbFiles.execute("data", null, false);
JdbcConnectionPool cp = JdbcConnectionPool.create(
"jdbc:h2:data/tr;TRACE_LEVEL_SYSTEM_OUT=3", "sa", "sa");
for (int i = 0; i < 10; i++) {
Connection c = cp.getConnection();
System.out.println("conn: " + c + " " + c.getClass().getName());
System.gc();
// c.close();
Thread.sleep(1000);
}
System.out.println("dispose------");
cp.dispose();
for (int i = 0; i < 10; i++) {
System.gc();
Thread.sleep(100);
}
I think what should happen is that the pooled connection is closed in the
finalizer.
First I tried to return the connection to the pool, but actually that doesn't
work
because the finalizers of both the pooled connection and the physical
connection are
called in the same garbage collection cycle. If this happens, the connection in
the
pool would be closed (which is really bad).
My fix is a bit different, I have now committed it to the trunk.
Regards,
Thomas
Original comment by thomas.t...@gmail.com
on 10 Jul 2009 at 4:16
Original comment by thomas.t...@gmail.com
on 10 Jul 2009 at 4:16
This bug is fixed with the latest release (1.1.116).
If there is still a problem, please open a new issue
or add a comment to this issue.
Original comment by thomas.t...@gmail.com
on 18 Jul 2009 at 9:55
Original issue reported on code.google.com by
ppced...@gmail.com
on 6 Jul 2009 at 1:59