Navigation Menu

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

Akka.Cluster and Akka.Cluster.Sharding: should throw human-friendly exception when accessing cluster / sharding plugins when clustering is not running #6163

Closed
Aaronontheweb opened this issue Oct 10, 2022 · 0 comments

Comments

@Aaronontheweb
Copy link
Member

Version Information
Version of Akka.NET? v1.4.43
Which Akka.NET Modules? Akka.Cluster, Akka.Cluster.Sharding

Describe the bug

When attempting to access the Cluster plugin when akka.actor.provider is not set to cluster:

var cluster = Cluster.Get(sys); // throws here
cluster.Join(cluster.SelfAddress);

// force cluster up

AwaitCondition(() => cluster.Members.Count(m => m.Status == Up) == 0);

Or the ClusterSharding plugin:

 shardingProxy = ClusterSharding // throws here
            .Get(Context.System)
            .Start(
                nameof(EntityActor),
                s => Props.Create(() => new EntityActor(s)),
                ClusterShardingSettings.Create(Context.System),
                new ShardingExtractor()
            );

The following exception is thrown:

resulting exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at Akka.Cluster.ClusterSettings..ctor(Config config, String systemName)
   at Akka.Cluster.Cluster..ctor(ActorSystemImpl system)
   at Akka.Cluster.ClusterExtension.CreateExtension(ExtendedActorSystem system)
   at Akka.Actor.ExtensionIdProvider`1.Akka.Actor.IExtensionId.CreateExtension(ExtendedActorSystem system)
   at Akka.Actor.Internal.ActorSystemImpl.<>c__DisplayClass61_0.<RegisterExtension>b__1()

Expected behavior

It would be better if a less ambiguous error message was raised - i.e. an AkkaConfigurationException warning uses that their akka.cluster.provider or akka.cluster configuration sections might be missing / misconfigured.

Actual behavior

A very ambiguous NRE that doesn't help new Akka.Cluster users understand how to fix their problem.

Additional context

Doesn't ClusterSharding also throw a weird error message if we aren't currently part of a cluster? Shouldn't we make that clearer as well?

@Aaronontheweb Aaronontheweb added this to the 1.4.44 milestone Oct 10, 2022
@Aaronontheweb Aaronontheweb changed the title Akka.Cluster and Akka.Cluster.Sharding: should throw human-friendly exception when accessing cluster / sharding pluigns when clustering is not running Akka.Cluster and Akka.Cluster.Sharding: should throw human-friendly exception when accessing cluster / sharding plugins when clustering is not running Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant