Skip to content

[#755] wait for the LDAP listener after in-process server (re)start#756

Merged
vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:issue-755-wait-for-ldap-listener-after-restart
Jul 21, 2026
Merged

[#755] wait for the LDAP listener after in-process server (re)start#756
vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:issue-755-wait-for-ldap-listener-after-restart

Conversation

@vharseko

Copy link
Copy Markdown
Member

Fixes #755.

Problem

BindOperationTestCase.testSubtreeModifyUpdatesAuthInfo failed once on CI with java.net.ConnectException: Connection refused on the very first RemoteConnection opened right after TestCaseUtils.restartServer(). The wait-for-listen handshake in LDAPConnectionHandler.start() used a bare waitListen.wait() with no condition predicate, so an early wakeup (spurious wakeup or interrupt) could let server startup return before the listen channel was actually bound — the first client connection then raced the bind and got refused. RemoteConnection connects exactly once, with no retry.

Fix

  • LDAPConnectionHandler (root cause): guard the wait with a listenAttempted condition predicate set at both notify sites in run() (after registerChannels() and in the !enabled startup branch), keeping the existing "notify in any case" semantics. Also restore the thread's interrupt flag when the wait is interrupted.
  • TestCaseUtils (test-side hardening): after server.start() in both startServer() and restartServer(), poll the LDAP port with a probe socket (TestTimer.repeatUntilSuccess, up to 10 s in 100 ms steps) until it actually accepts TCP connections. This covers all 13 test files that call restartServer() and connect right after, not just the two tests from the issue.

Testing

mvn -pl opendj-server-legacy verify -P precommit -Dit.test=BindOperationTestCase#testSubtreeDeleteClearsAuthInfo+testSubtreeModifyUpdatesAuthInfo — 2 tests passed, 2 in-core restarts exercised (both the initial-start and restart paths went through the new listener wait).

…rocess server (re)start

BindOperationTestCase.testSubtreeModifyUpdatesAuthInfo failed once on CI
with "Connection refused" on the first RemoteConnection right after
TestCaseUtils.restartServer(): the wait-for-listen handshake in
LDAPConnectionHandler.start() used a bare waitListen.wait() with no
condition predicate, so an early wakeup let startup return before the
listen channel was bound.

- LDAPConnectionHandler: guard the wait with a listenAttempted predicate
  set at both notify sites, and restore the interrupt flag on interrupt
- TestCaseUtils: poll the LDAP port until it actually accepts TCP
  connections after server.start() in startServer()/restartServer(),
  covering all tests that connect right after a restart
@vharseko
vharseko requested a review from maximthomas July 20, 2026 15:12
@vharseko vharseko added CI tests Test suites: fixing, enabling, un-disabling concurrency Thread-safety / race-condition bugs bug labels Jul 20, 2026
@vharseko vharseko changed the title Issue #755: wait for the LDAP listener after in-process server (re)start [#755] wait for the LDAP listener after in-process server (re)start Jul 20, 2026
@vharseko
vharseko merged commit f70033e into OpenIdentityPlatform:master Jul 21, 2026
28 of 29 checks passed
@vharseko
vharseko deleted the issue-755-wait-for-ldap-listener-after-restart branch July 21, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug CI concurrency Thread-safety / race-condition bugs tests Test suites: fixing, enabling, un-disabling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: BindOperationTestCase.testSubtreeModifyUpdatesAuthInfo — Connection refused right after in-process server restart

2 participants