if (subUnitOfWorks == null || subUnitOfWorks.isEmpty()) {
return;
}
// pop last sub unit of work as its now ended
SubUnitOfWork subUoW = subUnitOfWorks.pop();
if (subUoW.isFailed()) {
// the sub unit of work failed so set an exception containing all the caused exceptions
// and mark the exchange for rollback only
// if there are multiple exceptions then wrap those into another exception with them all
Exception cause;
List<Exception> list = subUoW.getExceptions();
if (list != null) {
if (list.size() == 1) {
cause = list.get(0);
} else {
cause = new CamelUnitOfWorkException(exchange, list);