Long tid = getLeaseTid(uuid);
TxnManagerTransaction txntr =
(TxnManagerTransaction)txns.get(tid);
if (txntr == null)
throw new UnknownLeaseException();
int state = txntr.getState();
//TODO - need better locking here. getState and expiration need to be checked atomically
if ((state == ACTIVE && txntr.getExpiration()==0) || (state != ACTIVE)) {
throw new UnknownLeaseException("unknown transaction");
}
if (state == ACTIVE) {
try {
synchronized (txntr) {
if(txntr.getExpiration() == 0) {
throw new TimeoutExpiredException("Transaction already expired", true);
}
txntr.setExpiration(0); // Mark as done
}
abort(((Long)tid).longValue(), false);
} catch (TransactionException e) {
throw new
UnknownLeaseException("When canceling abort threw:" +
e.getClass().getName() + ":" + e.getLocalizedMessage());
}
}