Skip to content

Commit

Permalink
Fix remoting logging DefaultAddress race condition (#7305)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkatufus authored Jul 26, 2024
1 parent 3eacb6c commit 3e2d49c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/Akka.Remote/RemoteActorRefProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public ActorPath RootPath
public Deployer Deployer { get; protected set; }

/// <inheritdoc/>
public Address DefaultAddress { get { return Transport.DefaultAddress; } }
public Address DefaultAddress { get { return Transport?.DefaultAddress; } }

private Information _serializationInformationCache;

Expand Down
11 changes: 9 additions & 2 deletions src/core/Akka/Event/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,15 @@ public static string FromActor(IActorContext actor, ActorSystem system)

public static string FromActorRef(IActorRef a, ActorSystem system)
{
var defaultAddress = system.AsInstanceOf<ExtendedActorSystem>().Provider.DefaultAddress;
return defaultAddress is null ? a.Path.ToString() : a.Path.ToStringWithAddress(defaultAddress);
try
{
var defaultAddress = system.AsInstanceOf<ExtendedActorSystem>().Provider.DefaultAddress;
return defaultAddress is null ? a.Path.ToString() : a.Path.ToStringWithAddress(defaultAddress);
}
catch // can fail if the ActorSystem (remoting) is not completely started yet
{
return a.Path.ToString();
}
}
}

Expand Down

0 comments on commit 3e2d49c

Please sign in to comment.