Conversation
Motivation: RemotingSpec "allow other system to connect even if it's not there at first" still fails intermittently in CI with `java.net.BindException: Address already in use` when the port from temporaryServerAddress() is taken before the new ActorSystem binds. The retry in selectionAndBind only fires when the exception message contains "Failed to bind", but classic Netty remoting rethrows the raw BindException from ActorSystem startup, so the guard never matched and the retry added in apache#3015 was dead code on this path. Modification: Add an isBindFailure helper that walks the cause chain and matches on java.net.BindException (keeping the "Failed to bind" message check for other transports), and use it as the retry guard in selectionAndBind. Add a directional test that starts an ActorSystem on a port already held by a ServerSocket and asserts the thrown exception is recognized by isBindFailure. Result: The lazy-connect tests retry on a fresh port when the temporary port is already in use instead of failing the suite. Tests: - scalafmt remote/src/test/scala/org/apache/pekko/remote/classic/RemotingSpec.scala - sbt "remote/testOnly org.apache.pekko.remote.classic.RemotingSpec" (23 tests, all passing) - git diff --check References: Refs apache#1679, Refs apache#3015 - port race in RemotingSpec lazy-connect tests
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.
Motivation
RemotingSpec"allow other system to connect even if it's not there at first" still fails intermittently in CI withjava.net.BindException: Address already in usewhen the port fromtemporaryServerAddress()is taken before the newActorSystembinds (seen again on #3549,Check / Tests (scala213)).The retry in
selectionAndBindonly fires when the exception message contains"Failed to bind", but classic Netty remoting rethrows the rawBindExceptionfromRemoting.start, so the guard never matched and the retry added in #3015 was effectively dead code on this path. That string only exists in the Artery TCP transport.Modification
isBindFailurehelper that walks the cause chain and matches onjava.net.BindException(keeping the"Failed to bind"message check for other transports), and use it as the retry guard inselectionAndBind.ActorSystemon a port already held by aServerSocketand asserts the thrown exception is recognized byisBindFailure(and that an unrelated exception is not). The old string guard returnsfalsefor this exception.Result
The lazy-connect tests retry on a fresh port when the temporary port is already in use instead of failing the suite.
Tests
scalafmt remote/src/test/scala/org/apache/pekko/remote/classic/RemotingSpec.scalasbt "remote/testOnly org.apache.pekko.remote.classic.RemotingSpec"— 23 tests, all passing (includes the new test)git diff --checkReferences
Refs #1679, Refs #3015 - port race in RemotingSpec lazy-connect tests