-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Fixed cluster group router UseRole ignored bug #3303
Fixed cluster group router UseRole ignored bug #3303
Conversation
@@ -272,7 +272,7 @@ private void A_cluster_must_group_local_on_role_b() | |||
var router = Sys.ActorOf( | |||
new ClusterRouterGroup( | |||
new RoundRobinGroup(paths: null), | |||
new ClusterRouterGroupSettings(6, ImmutableHashSet.Create("/user/foo", "/user/bar"), allowLocalRoutees: false, useRole: role)).Props(), | |||
new ClusterRouterGroupSettings(6, ImmutableHashSet.Create("/user/foo", "/user/bar"), allowLocalRoutees: true, useRole: role)).Props(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it turns out, this is a bug. allowLocalRoutees
is supposed to be set for true
for this part of the spec, per the JVM implementation for router-3b
:
ClusterRouterGroupSettings(totalInstances = 6, routeesPaths = List("/user/foo", "/user/bar"),
allowLocalRoutees = true, useRole = role)).props,
"router-3b")
This is why this spec didn't catch the bug earlier. The two bugs cancelled eachother out.
/// </summary> | ||
[Obsolete("Deprecated since Akka.NET v1.1. Use Paths(ActorSystem) instead.")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added note to indicate that this method is now obsolete, which it is.
Error logs upon re-running this spec with my changes:
|
@@ -145,13 +145,20 @@ public abstract class Group : RouterConfig, IEquatable<Group> | |||
/// <param name="routerDispatcher">TBD</param> | |||
protected Group(IEnumerable<string> paths, string routerDispatcher) : base(routerDispatcher) | |||
{ | |||
Paths = paths; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the real fix here. Needed to stop using the deprecated Paths
property so the router will fall back to calling the GetPaths(ActorSystem)
method instead, which does the right thing. Created a protected _paths
property to hold onto the value that will be used inside that method in most built-in routers, which is identical to what the JVM has.
@@ -4061,7 +4061,9 @@ namespace Akka.Routing | |||
} | |||
public abstract class Group : Akka.Routing.RouterConfig, System.IEquatable<Akka.Routing.Group> | |||
{ | |||
protected readonly string[] _paths; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really intended? ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep - the value has to be stored somewhere in order to be propagated inside local routers. We kind of effed ourselves by using an automatic property to set the value before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's intended to work this way, please correct the naming conventions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Horusiath done - renamed it to fix the ReSharper conventions.
@@ -167,7 +167,7 @@ public override void Start() | |||
var deprecatedPaths = group.Paths; | |||
|
|||
var paths = deprecatedPaths == null | |||
? group.GetPaths(System).ToArray() | |||
? group.GetPaths(System)?.ToArray() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The next line is call to paths.NonEmpty()
- if we're accepting to have paths
to be potentially null, this could end with NRE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paths.NonEmpty()
has a null-check built into it.
Bah, forgot to do API approvals |
* fixed bug in UseRoleIgnoredSpec * close #3294 - fixed usages of GetPaths inside all Group router implementations
* fixed bug in UseRoleIgnoredSpec * close #3294 - fixed usages of GetPaths inside all Group router implementations
Addresses #3294