- final Optional<ObjectName> taON = getTransaction();
- Preconditions.checkState(taON.isPresent(), "No transaction found for session " + netconfSessionIdForReporting);
- CommitStatus status = configRegistryClient.commitConfig(taON.get());
- allOpenedTransactions.remove(transaction);
- transaction = null;
- return status;
+ final Optional<ObjectName> maybeTaON = getTransaction();
+ Preconditions.checkState(maybeTaON.isPresent(), "No transaction found for session " + netconfSessionIdForReporting);
+ ObjectName taON = maybeTaON.get();
+ try {
+ CommitStatus status = configRegistryClient.commitConfig(taON);
+ // clean up
+ allOpenedTransactions.remove(transaction);
+ transaction = null;
+ return status;
+ } catch (ValidationException validationException) {
+ // no clean up: user can reconfigure and recover this transaction
+ logger.warn("Transaction {} failed on {}", taON, validationException.toString());
+ throw validationException;
+ } catch (Exception e) {
+ logger.error("Exception while commit of {}, aborting transaction", taON, e);
+ // clean up
+ abortTransaction();
+ throw e;
+ }