Skip to content

Commit 5cc8916

Browse files
metanetmdogan
authored andcommitted
Fix acquire retry idempotency in RaftSemaphore
1 parent 0bb6683 commit 5cc8916

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • hazelcast-raft-dataservices/src/main/java/com/hazelcast/raft/service/semaphore

hazelcast-raft-dataservices/src/main/java/com/hazelcast/raft/service/semaphore/RaftSemaphore.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,13 @@ boolean isAvailable(int permits) {
9393
}
9494

9595
AcquireResult acquire(SemaphoreInvocationKey key, boolean wait) {
96+
SessionState state = sessionStates.get(key.sessionId());
97+
if (state != null && state.acquires.containsKey(key.invocationUid())) {
98+
return new AcquireResult(key.permits(), Collections.<SemaphoreInvocationKey>emptyList());
99+
}
100+
96101
Collection<SemaphoreInvocationKey> cancelled = cancelWaitKeys(key.sessionId(), key.threadId(), key.invocationUid());
102+
97103
if (!isAvailable(key.permits())) {
98104
if (wait) {
99105
waitKeys.add(key);

0 commit comments

Comments
 (0)