From 4463fcb312168d17e64fec92989c0dd1d43576bf Mon Sep 17 00:00:00 2001 From: Igor Fedchenko Date: Mon, 13 Jan 2020 21:56:33 +0300 Subject: [PATCH] Close collection to TcpConnection actor on test runner stop (#4139) --- src/core/Akka.NodeTestRunner/Program.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/core/Akka.NodeTestRunner/Program.cs b/src/core/Akka.NodeTestRunner/Program.cs index 10d1284c1f0..5931820829f 100644 --- a/src/core/Akka.NodeTestRunner/Program.cs +++ b/src/core/Akka.NodeTestRunner/Program.cs @@ -161,16 +161,32 @@ private static Assembly DefaultOnResolving(AssemblyLoadContext assemblyLoadConte class RunnerTcpClient : ReceiveActor, IWithUnboundedStash { + private IActorRef _connection; + public RunnerTcpClient() { Become(WaitingForConnection); } + /// + protected override void PostStop() + { + // Close connection property to avoid exception logged at TcpConnection actor once this actor is terminated + try + { + _connection.Ask(Tcp.Close.Instance, TimeSpan.FromSeconds(1)).Wait(); + } + catch { /* well... at least we have tried */ } + + base.PostStop(); + } + private void WaitingForConnection() { Receive(connected => { Sender.Tell(new Tcp.Register(Self)); + _connection = Sender; Become(Connected(Sender)); }); Receive(_ => Stash.Stash());