Skip to content

Test for a free port instead of guessing from a restricted range - #68

Open
dwalluck wants to merge 1 commit into
Commonjava:masterfrom
dwalluck:fix-free-port
Open

Test for a free port instead of guessing from a restricted range#68
dwalluck wants to merge 1 commit into
Commonjava:masterfrom
dwalluck:fix-free-port

Conversation

@dwalluck

Copy link
Copy Markdown
Contributor

Fix retry not handling RuntimeException.

Record the last exception.

Fix retry not handling `RuntimeException`.

Record the last exception.
@dwalluck
dwalluck requested a review from rnc August 24, 2026 15:58
@rnc

rnc commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Looks like the code was changed and commented out by @jdcasey with a comment about a race condition

@dwalluck

Copy link
Copy Markdown
Contributor Author

Looks like the code was changed and commented out by @jdcasey with a comment about a race condition

Let me list the issues I found with the current code and why I changed anything at all since I didn't put a thorough commit message:

  1. It was restricting the port range seemingly unnecessarily. I was actually hitting an exception (inside Docker), which is how I noticed. The idea is to pass port 0, and let the OS pick the port.
  2. When it hit the exception, it wasn't handling it. It throws BindException (IOException) when it can't bind to the port. The code catches IOException, so it looks like it handles it, except the actual exception thrown appears to be inside a RuntimeException from Undertow.
  3. The actual exception/cause was being lost, which is why I store it and then rethrow.

@dwalluck
dwalluck requested a review from jdcasey August 25, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants