Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

Commit 6964720

Browse files
committed
Handle only LockNotGrantedException for heartbeat
If we don't have a connection to AWS or our thread is interrupted for some reason, we should just re-throw that exception as is. * Only catch a `LockNotGrantedException` which really indicates that the state of the lock record has been changed. Therefore we also have to reset local state and try again
1 parent 6b0933c commit 6964720

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/java/org/springframework/integration/aws/lock/DynamoDbLockRegistry.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import com.amazonaws.services.dynamodbv2.model.CreateTableRequest;
5757
import com.amazonaws.services.dynamodbv2.model.KeySchemaElement;
5858
import com.amazonaws.services.dynamodbv2.model.KeyType;
59+
import com.amazonaws.services.dynamodbv2.model.LockNotGrantedException;
5960
import com.amazonaws.services.dynamodbv2.model.LockTableDoesNotExistException;
6061
import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput;
6162
import com.amazonaws.services.dynamodbv2.model.ResourceInUseException;
@@ -532,7 +533,7 @@ private boolean doLock() throws InterruptedException {
532533
this.lockItem.sendHeartBeat();
533534
acquired = true;
534535
}
535-
catch (Exception e) {
536+
catch (LockNotGrantedException ex) {
536537
// May be no lock record in the DB - discard local holder and try to lock again
537538
this.lockItem = null;
538539
}

0 commit comments

Comments
 (0)