mirror of https://github.com/apache/cloudstack.git
guard GlobalLock lock with finally clause
This commit is contained in:
parent
41759c153d
commit
d9392a6aa7
|
|
@ -105,26 +105,28 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom
|
|||
s_logger.error("Unable to lock parent domain: " + parent);
|
||||
return null;
|
||||
}
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
|
||||
domain.setPath(allocPath(parentDomain, domain.getName()));
|
||||
domain.setLevel(parentDomain.getLevel() + 1);
|
||||
|
||||
parentDomain.setNextChildSeq(parentDomain.getNextChildSeq() + 1); // FIXME: remove sequence number?
|
||||
parentDomain.setChildCount(parentDomain.getChildCount() + 1);
|
||||
persist(domain);
|
||||
update(parentDomain.getId(), parentDomain);
|
||||
|
||||
txn.commit();
|
||||
return domain;
|
||||
} catch(Exception e) {
|
||||
s_logger.error("Unable to create domain due to " + e.getMessage(), e);
|
||||
txn.rollback();
|
||||
return null;
|
||||
} finally {
|
||||
|
||||
try {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
|
||||
domain.setPath(allocPath(parentDomain, domain.getName()));
|
||||
domain.setLevel(parentDomain.getLevel() + 1);
|
||||
|
||||
parentDomain.setNextChildSeq(parentDomain.getNextChildSeq() + 1); // FIXME: remove sequence number?
|
||||
parentDomain.setChildCount(parentDomain.getChildCount() + 1);
|
||||
persist(domain);
|
||||
update(parentDomain.getId(), parentDomain);
|
||||
|
||||
txn.commit();
|
||||
return domain;
|
||||
} catch(Exception e) {
|
||||
s_logger.error("Unable to create domain due to " + e.getMessage(), e);
|
||||
txn.rollback();
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue