Index: ./src/main/org/exolab/castor/jdo/engine/DatabaseImpl.java =================================================================== RCS file: /home/projects/castor/scm/castor/src/main/org/exolab/castor/jdo/engine/DatabaseImpl.java,v retrieving revision 1.34 diff -u -r1.34 DatabaseImpl.java --- ./src/main/org/exolab/castor/jdo/engine/DatabaseImpl.java 10 Feb 2006 19:34:06 -0000 1.34 +++ ./src/main/org/exolab/castor/jdo/engine/DatabaseImpl.java 13 Mar 2006 19:13:14 -0000 @@ -475,10 +475,13 @@ * @see java.lang.Object#finalize() */ protected void finalize() throws Throwable { - if (_scope != null) { + if (_scope != null || !_ctx.isOpen()) { + return; + } - if (_ctx instanceof LocalTransactionContext || - (_ctx instanceof GlobalTransactionContext && !_isPoolInUseForGlobalTransactions)) { + if (_ctx instanceof LocalTransactionContext || + (_ctx instanceof GlobalTransactionContext && + !_isPoolInUseForGlobalTransactions)) { // retrieve SQL bound to this Database instance OQLQuery oqlQuery = getOQLQuery(); String sql = ((OQLQueryImpl) oqlQuery).getSQL(); @@ -543,7 +546,7 @@ throw except; } finally { try { - // TODO [SMH]: Temporary fix, see bug 1491. + // TODO [SMH]: Temporary fix, see bug 1491/CASTOR-630. if(_ctx.isOpen()) { _ctx.close(); }