public synchronized void abortTransaction() {
LOG.debug("Aborting current candidateTransaction");
Optional<DOMDataReadWriteTransaction> otx = getCandidateTransaction();
- Preconditions.checkState(otx.isPresent(), NO_TRANSACTION_FOUND_FOR_SESSION + netconfSessionIdForReporting);
+ if (!otx.isPresent()) {
+ LOG.warn("discard-changes triggerd on an empty transaction for session: {}", netconfSessionIdForReporting );
+ return;
+ }
candidateTransaction.cancel();
allOpenReadWriteTransactions.remove(candidateTransaction);
candidateTransaction = null;
assertEmptyDatastore(getConfigRunning());
}
- @Test
- public void testDiscard() throws Exception {
-
- try {
- discardChanges();
- fail("Should have failed, need to execute an edit before discard");
- } catch (DocumentedException e) {
- assertTrue(e.getErrorSeverity() == ErrorSeverity.error);
- assertTrue(e.getErrorTag() == ErrorTag.operation_failed);
- assertTrue(e.getErrorType() == ErrorType.application);
- }
- }
-
@Test
public void testIncorrectGet() throws Exception {