Search in sources :

Example 1 with TransactionFailedNonRetriableException

use of com.palantir.atlasdb.transaction.api.TransactionFailedNonRetriableException in project atlasdb by palantir.

the class SnapshotTransactionTest method runWithRetryFailsOnNonRetriableException.

@Test
public void runWithRetryFailsOnNonRetriableException() {
    PreCommitCondition nonRetriableFailure = new PreCommitCondition() {

        @Override
        public void throwIfConditionInvalid(long timestamp) {
            throw new TransactionFailedNonRetriableException("Condition failed");
        }

        @Override
        public void cleanup() {
        }
    };
    Supplier<PreCommitCondition> conditionSupplier = Suppliers.ofInstance(nonRetriableFailure);
    try {
        serializableTxManager.runTaskWithConditionWithRetry(conditionSupplier, (tx, condition) -> {
            tx.put(TABLE, ImmutableMap.of(TEST_CELL, PtBytes.toBytes("value")));
            return null;
        });
        fail();
    } catch (TransactionFailedNonRetriableException e) {
        assertThat(e.getMessage(), containsString("Condition failed"));
    }
}
Also used : TransactionFailedNonRetriableException(com.palantir.atlasdb.transaction.api.TransactionFailedNonRetriableException) PreCommitCondition(com.palantir.atlasdb.transaction.api.PreCommitCondition) Test(org.junit.Test)

Aggregations

PreCommitCondition (com.palantir.atlasdb.transaction.api.PreCommitCondition)1 TransactionFailedNonRetriableException (com.palantir.atlasdb.transaction.api.TransactionFailedNonRetriableException)1 Test (org.junit.Test)1