@Override public CompletionStage<Void> end() throws TransactionException { // check active if (!isActive()) { throw new IllegalTransactionStatusException("The transaction is not active"); } // check completed if (!isCompleted()) { if (isRollbackOnly()) { return rollback(); } else { if (getConfiguration().isAutoCommit()) { return commit().thenApply(r -> null); } } } LOGGER.debug(() -> "MongoDB transaction [" + this + "] finalized"); return CompletableFuture.completedFuture(null); }
/** * Finalize the transaction. * @throws TransactionException If an error occurred */ protected void endTransaction() throws TransactionException { getTransactionStatus().ifPresent(tx -> { if (!tx.isCompleted()) { try { if (isRollbackOnly()) { getTransactionManager().rollback(tx); } else { if (getConfiguration().isAutoCommit()) { getTransactionManager().commit(tx); } } } catch (Exception e) { throw new TransactionException("Failed to finalize transaction", e); } } }); }
@Override public void end() throws TransactionException { // check active if (!isActive()) { throw new IllegalTransactionStatusException("The transaction is not active"); } // check completed if (!isCompleted()) { if (isRollbackOnly()) { rollback(); } else { if (getConfiguration().isAutoCommit()) { commit(); } } } LOGGER.debug(() -> "MongoDB transaction [" + this + "] finalized"); }