public synchronized void rollback()

in src/main/java/com/amazonaws/services/dynamodbv2/transactions/Transaction.java [512:549]


    public synchronized void rollback() throws TransactionCompletedException, UnknownCompletedTransactionException {
        State state = null;
        boolean alreadyRereadTxItem = false;
        try {
            txItem.finish(State.ROLLED_BACK, txItem.getVersion());  
            state = State.ROLLED_BACK;
        } catch (ConditionalCheckFailedException e) {         
            try {
                // Re-read state to see its actual state, since it wasn't in PENDING
                txItem = new TransactionItem(txId, txManager, false);
                alreadyRereadTxItem = true;
                state = txItem.getState();
            } catch (TransactionNotFoundException tnfe) {
                throw new UnknownCompletedTransactionException(txId, "In transaction " + State.ROLLED_BACK + " attempt, transaction either rolled back or committed");
            }
        }
        
        if(State.COMMITTED.equals(state)) {
            if(! txItem.isCompleted()) {
                doCommit();
            }
            throw new TransactionCommittedException(txId, "Transaction was committed");
        } else if(State.ROLLED_BACK.equals(state)) {
            if(! txItem.isCompleted()) {
                doRollback();
            }
            return;
        } else if (State.PENDING.equals(state)) {
            if (! alreadyRereadTxItem) {
                // The item was modified in the meantime (another request was added to it)
                // so make sure we re-read it, and then try the rollback again
                txItem = new TransactionItem(txId, txManager, false);
            }
            rollback();
            return;
        }
        throw new TransactionAssertionException(txId, "Unexpected state in rollback(): " + state);
    }