This is an automated email from the ASF dual-hosted git repository.

He-Pin pushed a commit to branch fix/remoting-spec-address-in-use
in repository https://gitbox.apache.org/repos/asf/pekko.git

commit 923bde3db7dee6d7082976268f76956e4c30a0ee
Author: He-Pin <[email protected]>
AuthorDate: Fri May 29 23:27:00 2026 +0800

    test: retry temporary port bind in RemotingSpec lazy-connect test
    
    Motivation:
    RemotingSpec "allow other system to connect even if it's not there at first"
    intermittently fails at ActorSystem startup with "Address already in use"
    (issue #1679). The test allocates a port via temporaryServerAddress() and
    then binds a new ActorSystem to it; the port can be claimed by another
    process between allocation and bind.
    
    Modification:
    Reuse the existing selectionAndBind helper (already used by the sibling
    "be able to connect to system even if it's not there at first" test), which
    retries on a fresh port when the bind fails with "Failed to bind".
    
    Result:
    The lazy-connect test no longer races temporary port allocation; it still
    passes locally.
    
    References:
    Fixes #1679
---
 .../org/apache/pekko/remote/classic/RemotingSpec.scala      | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git 
a/remote/src/test/scala/org/apache/pekko/remote/classic/RemotingSpec.scala 
b/remote/src/test/scala/org/apache/pekko/remote/classic/RemotingSpec.scala
index 335af689dd..0fb42195e8 100644
--- a/remote/src/test/scala/org/apache/pekko/remote/classic/RemotingSpec.scala
+++ b/remote/src/test/scala/org/apache/pekko/remote/classic/RemotingSpec.scala
@@ -836,17 +836,10 @@ class RemotingSpec extends PekkoSpec(RemotingSpec.cfg) 
with ImplicitSender with
       try {
         muteSystem(thisSystem)
         val thisProbe = new TestProbe(thisSystem)
-        val thisSender = thisProbe.ref
         thisSystem.actorOf(Props[Echo2](), "echo")
-        val otherAddress = temporaryServerAddress()
-        val otherConfig = ConfigFactory.parseString(s"""
-              pekko.remote.classic.netty.tcp.port = ${otherAddress.getPort}
-              """).withFallback(config)
-        val otherSelection =
-          
thisSystem.actorSelection(s"pekko.tcp://other-system@localhost:${otherAddress.getPort}/user/echo")
-        otherSelection.tell("ping", thisSender)
-        thisProbe.expectNoMessage(1.seconds)
-        val otherSystem = ActorSystem("other-system", otherConfig)
+        // selectionAndBind retries on a fresh port, since the 
temporaryServerAddress can be taken
+        // by the time the new actor system binds (see #1679)
+        val (otherSystem, _) = selectionAndBind(config, thisSystem, thisProbe)
         try {
           muteSystem(otherSystem)
           thisProbe.expectNoMessage(2.seconds)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to