Skip to content

OF-3482: Fix race when collecting outgoing connection results - #3590

Open
akrherz wants to merge 1 commit into
igniterealtime:mainfrom
akrherz:dns_override_mac
Open

akrherz wants to merge 1 commit into
igniterealtime:mainfrom
akrherz:dns_override_mac

Conversation

@akrherz

@akrherz akrherz commented Nov 30, 2026

Copy link
Copy Markdown
Member

A connection attempt can succeed after the resolver thread finishes but before its result is published. SocketUtil could return no connection without collecting that result, causing intermittent failures. Track submitted attempts until their results are collected or the deadline expires.

Co-pilot suggested to me that this is a source of our CI flapping tests.

A connection attempt can succeed after the resolver thread finishes but before its result is published. SocketUtil could return no connection without collecting that result, causing intermittent failures. Track submitted attempts until their results are collected or the deadline expires.
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

createSocket now delegates connection-result polling to awaitConnection. The helper polls completed futures in intervals of up to two seconds, logs and ignores ExecutionExceptions, and returns a connection or null when its stopping conditions are met. Tests cover a failed attempt followed by a successful attempt and a finished resolver with no attempts.

Suggested reviewers: guusdk, viv

Merge Risk: Minimal · up to 9f5e2

This change fixes a race where an outgoing connection that succeeds just after its resolver finishes could be missed. It now keeps polling until every submitted attempt has been collected or the deadline expires. No remaining merge-blocking risk was found.

Pre-merge checks: Passed 3

Check name Status Explanation
Description check Passed The description states a specific race condition: a connection attempt can succeed after the resolver thread finishes but before its result is published, so SocketUtil can return no connection without…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description states a specific race condition: a connection attempt can succeed after the resolver thread finishes but before its result is published, so SocketUtil can return no connection without collecting that result. It also states the fix, which tracks submitted attempts until their results are collected or the deadline expires. This matches the changeset, which adds awaitConnection to SocketUtil and tests for it. The author's suggestion that this causes CI flapping is unconfirmed, but the check only requires relevance to the changeset.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e2f8e2ec-f764-4d5d-a64c-ff07e20fac74
Commits

Reviewing files that changed from the base of the PR and between 6f177cd and 9f5e201.

Files selected for processing: 2

  • xmppserver/src/main/java/org/jivesoftware/openfire/net/SocketUtil.java
  • xmppserver/src/test/java/org/jivesoftware/openfire/net/SocketUtilTest.java

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@akrherz
akrherz requested a balanced review from Copilot November 30, 2026 19:52
@akrherz akrherz added the backport 5.1 on merge, GHA will generate a PR with these changes against 5.1 branch label Nov 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the outgoing XMPP connection race fix.

No open issues 🎉

What changed in this PR

Fixes a race in outgoing XMPP connection handling where SocketUtil could miss a successful connection published after the resolver thread finished.

Changes:

  • Extracts result collection into awaitConnection, which waits until a connection succeeds, all submitted results are collected, or the deadline expires.
  • Adds regression tests for delayed result publication and a finished resolver with no connection attempts.
File Description
xmppserver/​src/​test/​java/​org/​jivesoftware/​openfire/​net/​SocketUtilTest.java Tests delayed success after a failed attempt and the no-attempt case.
xmppserver/​src/​main/​java/​org/​jivesoftware/​openfire/​net/​SocketUtil.java Tracks uncollected connection results beyond resolver termination.

Review effort: Balanced

@akrherz

akrherz commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

Green once, tempting fate and restarting.

@akrherz akrherz closed this Nov 30, 2026
@akrherz akrherz reopened this Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 5.1 on merge, GHA will generate a PR with these changes against 5.1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants