public void finish()

in src/main/java/com/amazonaws/services/dynamodbv2/transactions/TransactionItem.java [477:504]


    public void finish(final State targetState, final int expectedVersion) throws ConditionalCheckFailedException {
        txAssert(State.COMMITTED.equals(targetState) || State.ROLLED_BACK.equals(targetState),"Illegal state in finish(): " + targetState, "txItem", txItem);
        Map<String, ExpectedAttributeValue> expected = new HashMap<String, ExpectedAttributeValue>(2);
        expected.put(AttributeName.STATE.toString(), new ExpectedAttributeValue().withValue(new AttributeValue().withS(STATE_PENDING)));
        expected.put(AttributeName.FINALIZED.toString(), new ExpectedAttributeValue().withExists(false));
        expected.put(AttributeName.VERSION.toString(), new ExpectedAttributeValue().withValue(new AttributeValue().withN(Integer.toString(expectedVersion))));
        
        Map<String, AttributeValueUpdate> updates = new HashMap<String, AttributeValueUpdate>();
        updates.put(AttributeName.STATE.toString(), new AttributeValueUpdate()
            .withAction(AttributeAction.PUT)
            .withValue(new AttributeValue(stateToString(targetState))));
        updates.put(AttributeName.DATE.toString(), new AttributeValueUpdate()
            .withAction(AttributeAction.PUT)
            .withValue(txManager.getCurrentTimeAttribute()));
        
        UpdateItemRequest finishRequest = new UpdateItemRequest()
            .withTableName(txManager.getTransactionTableName())
            .withKey(txKey)
            .withAttributeUpdates(updates)
            .withReturnValues(ReturnValue.ALL_NEW)
            .withExpected(expected);
        
        UpdateItemResult finishResult = txManager.getClient().updateItem(finishRequest);
        txItem = finishResult.getAttributes();
        if(txItem == null) {
            throw new TransactionAssertionException(txId, "Unexpected null tx item after committing " + targetState);
        }
    }