Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix remoting logging DefaultAddress race condition #7305

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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; } }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure we return null instead of throwing an NRE if Transport is still null.


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();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second guard to make sure that, in the event that any exception is thrown, we still return a valid actor path

}
}

Expand Down
Loading