awslabs / amazon-dynamodb-lock-client

The AmazonDynamoDBLockClient is a general purpose distributed locking library built on top of DynamoDB. It supports both coarse-grained and fine-grained locking.
Other
472 stars 85 forks source link

Make acquireLock() reentrant #56

Closed lcabancla closed 3 years ago

lcabancla commented 3 years ago

If a client already owns a lock and acquireLock() is called, the call blocks and fails.

Test case:

    @Test
    public void testAcquireLockMultipleTimes() throws InterruptedException {
        LockItem item = this.lockClientWithHeartbeating.acquireLock(AcquireLockOptions.builder("testKey1").build());
        this.lockClientWithHeartbeating.acquireLock(AcquireLockOptions.builder("testKey1").build());
        item.close();
    }