Fix deadlock in adapter access tests across named-lock modules - #2033
Open
elharo wants to merge 1 commit into
Open
Fix deadlock in adapter access tests across named-lock modules#2033elharo wants to merge 1 commit into
elharo wants to merge 1 commit into
Conversation
NamedLockFactoryAdapterTestSupport has the same deadlock-prone winner/loser handshake as NamedLockFactoryTestSupport: when both competing threads fail to acquire the lock within the adapter lock wait time, both count down the loser latch and then block forever on winner.await(), so the winners latch is never released and the test hangs until @timeout fires. Fix the copies in the ipc, hazelcast, redisson and maven-resolver-impl modules: - raise ADAPTER_TIME from 100 ms (500 ms in impl) to 1 s so at least one thread reliably wins even on a loaded machine; the loser is still queued behind the winner, so mutual exclusion is still verified - bound the winner/loser handshake and the test-side joins and latch awaits, and assert the expected outcome, so a pathological both-lose case fails fast with a clear message instead of hanging - bump the @timeout(5) safety nets to @timeout(15) to leave room for the longer loser path (2 attempts x ADAPTER_TIME + retry wait) This complements #2032 for the adapter-level tests.
gnodet
approved these changes
Aug 4, 2026
gnodet
left a comment
Contributor
There was a problem hiding this comment.
Clean, consistent application of the #2032 deadlock fix pattern to all four copies of NamedLockFactoryAdapterTestSupport (IPC, Hazelcast, Redisson, impl). Every unbounded join() and await() is now bounded with 5s timeouts, ADAPTER_TIME raised to 1000ms uniformly, and test-level assertions provide clear diagnostics.
Nice that this covers all four modules — exactly the follow-up we noted in the #2032 review.
This review was generated by an AI agent (Claude Code) and may contain inaccuracies. Please verify all suggestions before applying.
On behalf of gnodet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Complements #2032 by fixing the same deadlock-prone handshake in NamedLockFactoryAdapterTestSupport (used by IpcAdapterIT, IpcAdapterNoForkIT, the hazelcast/redisson adapter ITs, and the LocalReadWriteLock/FileLock/LocalSemaphore adapter tests).
Problem
When both competing threads fail to acquire the lock within the adapter lock wait time (ADAPTER_TIME, default 100 ms, with 1 retry), both Access threads count down the loser latch and then block forever on winner.await(), because the winners latch is never counted down. The tests hang until the JUnit @timeout fires. Under load (e.g. the in-process IPC server thread starved for more than 100 ms) neither acquisition completes in time, so this deadlocks exactly like the factory-level tests in #2032.
Fix
Applied to all four copies of NamedLockFactoryAdapterTestSupport (maven-resolver-named-locks-ipc, -hazelcast, -redisson and maven-resolver-impl):
Verification