Search in sources :

Example 1 with TransactionLockTimeoutNonRetriableException

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

the class SnapshotTransactionTest method noRetryOnExpiredLockTokens.

@Test
public void noRetryOnExpiredLockTokens() throws InterruptedException {
    HeldLocksToken expiredLockToken = getExpiredHeldLocksToken();
    try {
        txManager.runTaskWithLocksWithRetry(ImmutableList.of(expiredLockToken), () -> null, (tx, locks) -> {
            tx.put(TABLE, ImmutableMap.of(TEST_CELL, PtBytes.toBytes("value")));
            return null;
        });
        fail();
    } catch (TransactionLockTimeoutNonRetriableException e) {
        Set<LockRefreshToken> expectedTokens = ImmutableSet.of(expiredLockToken.getLockRefreshToken());
        assertThat(e.getMessage(), containsString(expectedTokens.toString()));
        assertThat(e.getMessage(), containsString("Retry is not possible."));
    }
}
Also used : Set(java.util.Set) ImmutableSet(com.google.common.collect.ImmutableSet) HeldLocksToken(com.palantir.lock.HeldLocksToken) TransactionLockTimeoutNonRetriableException(com.palantir.atlasdb.transaction.api.TransactionLockTimeoutNonRetriableException) Test(org.junit.Test)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)1 TransactionLockTimeoutNonRetriableException (com.palantir.atlasdb.transaction.api.TransactionLockTimeoutNonRetriableException)1 HeldLocksToken (com.palantir.lock.HeldLocksToken)1 Set (java.util.Set)1 Test (org.junit.Test)1