You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by sclark <sc...@detox.cr.usgs.gov> on 2003/05/15 18:53:55 UTC
Transaction.abort() throws NPE
I have seen this issue come across the list a couple of times, but have not seen
a definitive resolution.
Should the 'finally' block in the following code work?
Implementation odmg = ...;
Transaction tx = null;
try {
boolean res = false;
tx = odmg.newTransaction();
tx.begin();
... do stuff
tx.commit();
return res;
}
// Always make sure the transaction has been closed before returning.
finally {
// If we haven't committed, an error must have occurred, so we
// need to rollback.
if ((tx != null) && tx.isOpen()) {
tx.abort();
}
}
Any time that commit() fails, I am finding tx.isOpen() == true, and the
subsequent call to abort() throws NPE in TransactionImpl.doClose().
If commit() throws, should I assume that the tx is hosed and not try to clean
up? or is this a bug?
thanks,
-steve
Steve Clark
Technology Applications Team
Natural Resources Research Center/USGS
sclark@detox.cr.usgs.gov
(970)226-9291