/**
* Test that a failure in isPrepared during commit doesn't cause the commit
* to fail to clear the thread context.
*/
public void testIsPreparedFailsDuringCommit() throws Exception {
DummyTransactionProxy txnProxy = new DummyTransactionProxy();
TransactionContextFactory<TransactionContext> contextFactory =
new TransactionContextFactory<TransactionContext>(txnProxy,
"TestTransactionContextFactory")
{
protected TransactionContext createContext(Transaction txn) {
return new TransactionContext(txn) {
public boolean isPrepared() {
if (isPrepared) {
throw new RuntimeException(
"isPrepared fails during commit");
} else {
return false;
}
}
public void abort(boolean retryable) { }
public void commit() { }
};
}
};
DummyTransaction txn = new DummyTransaction(
DummyTransaction.UsePrepareAndCommit.NO);
txnProxy.setCurrentTransaction(txn);
contextFactory.joinTransaction();
txn.commit();
txn = new DummyTransaction();
txnProxy.setCurrentTransaction(txn);
contextFactory.joinTransaction();
txn.commit();
}