use of org.osgi.service.transaction.control.TransactionStatus.ROLLING_BACK in project aries by apache.
the class TransactionContextImpl method finish.
@Override
public void finish() {
beforeCompletion(() -> setRollbackOnly());
TransactionStatus status;
if (getRollbackOnly()) {
vanillaRollback();
status = ROLLED_BACK;
} else {
tranStatus.set(COMMITTING);
List<LocalResource> committed = new ArrayList<>(resources.size());
List<LocalResource> rolledback = new ArrayList<>(0);
resources.stream().forEach(lr -> {
try {
if (getRollbackOnly()) {
lr.rollback();
rolledback.add(lr);
} else {
lr.commit();
committed.add(lr);
}
} catch (Exception e) {
firstUnexpectedException.compareAndSet(null, e);
if (committed.isEmpty()) {
tranStatus.set(ROLLING_BACK);
}
rolledback.add(lr);
}
});
status = tranStatus.updateAndGet(ts -> ts == ROLLING_BACK ? ROLLED_BACK : COMMITTED);
}
afterCompletion(status);
}
Aggregations