Skip to content

Commit 3e2d49c

Browse files
authored
Fix remoting logging DefaultAddress race condition (#7305)
1 parent 3eacb6c commit 3e2d49c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/core/Akka.Remote/RemoteActorRefProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public ActorPath RootPath
189189
public Deployer Deployer { get; protected set; }
190190

191191
/// <inheritdoc/>
192-
public Address DefaultAddress { get { return Transport.DefaultAddress; } }
192+
public Address DefaultAddress { get { return Transport?.DefaultAddress; } }
193193

194194
private Information _serializationInformationCache;
195195

src/core/Akka/Event/Logging.cs

+9-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,15 @@ public static string FromActor(IActorContext actor, ActorSystem system)
112112

113113
public static string FromActorRef(IActorRef a, ActorSystem system)
114114
{
115-
var defaultAddress = system.AsInstanceOf<ExtendedActorSystem>().Provider.DefaultAddress;
116-
return defaultAddress is null ? a.Path.ToString() : a.Path.ToStringWithAddress(defaultAddress);
115+
try
116+
{
117+
var defaultAddress = system.AsInstanceOf<ExtendedActorSystem>().Provider.DefaultAddress;
118+
return defaultAddress is null ? a.Path.ToString() : a.Path.ToStringWithAddress(defaultAddress);
119+
}
120+
catch // can fail if the ActorSystem (remoting) is not completely started yet
121+
{
122+
return a.Path.ToString();
123+
}
117124
}
118125
}
119126

0 commit comments

Comments
 (0)