Thanks for the quick response on 0.9.11!  Except it makes me feel a bit
ungrateful to have to report another bug now - hopefully this'll be my last
one for a while.  This is a related problem, which affects 0.9.9 and
earlier.  I haven't yet actually tested it with 0.9.11, but the relevant
code looks the same.

Once the autoclose problem was fixed, I started getting warnings in my log
(the new logging is working beautifully, btw.)  The warnings were from
RelationalDatabaseSession.finalize(), about an "unclosed connection".
Investigation showed that the connection in question was in fact already
closed (by me, externally), and that finalize() was closing it a second
time.  Resin's connection wrapper didn't seem to mind this, so it didn't
actually cause any direct symptoms for me, other than the log warning.

The real problem seems to be that disconnect() doesn't set conn=null when
autoclose is off, which leads finalize() to think that the session still has
a valid connection.  I fixed it by changing the try block in disconnect() to
the following:

        try {
                closeStatements();
                Connection c = conn;
                conn=null;
                if (autoClose) {
                        factory.closeConnection(c);
                        return null;
                }
                else {
                        return c;
                }
        }

This seems to fix it, at least in my tests.  I don't think it's necessary to
add any guards to finalize() itself, as long as conn gets set to null when
it's supposed to.

A similar problem exists in commit() and cancel(), but I didn't bother to
fix them since they're deprecated.  Of course, they're trivial to fix.

BTW, this problem might seem fairly benign - just a log warning, as long as
your connections don't mind being closed twice.  But in theory, it would be
possible for finalize() to trigger after an externally-pooled connection has
been reactivated, and thus close an active connection.  That might have been
fun to track down!  ;)

Anton


_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
Hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to