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

AK1002 false positive #69

Closed
Aaronontheweb opened this issue Feb 16, 2024 · 0 comments · Fixed by #72
Closed

AK1002 false positive #69

Aaronontheweb opened this issue Feb 16, 2024 · 0 comments · Fixed by #72

Comments

@Aaronontheweb
Copy link
Member

Version Information
Version of Akka.NET? Akka.NET v1.5.16, Akka.Analyzers v0.2.2

Describe the bug

This code is currently flagged as an error by AK1002:

ReceiveAsync<StopActor>(async p =>
{
    try
    {
        var actorSelection = Context.System.ActorSelection(p.ActorPath);
       
        var actorRef = await actorSelection.ResolveOne(p.Timeout);

        var stopped = await actorRef.GracefulStop(p.Timeout); // AK1002 false positive occurs here
        if(stopped)
            Sender.Tell(new CommandResponse($"Successfully terminated [{p.ActorPath}] within [{p.Timeout}]"));
        else
            Sender.Tell(new ErroredCommandResponse($"Failed to terminate [{p.ActorPath}] within [{p.Timeout}]"));
    }
    catch (ActorNotFoundException)
    {
        Sender.Tell(new CommandResponse($"No actor found at [{p.ActorPath}] - no termination required"));
    }
    catch (Exception e)
    {
        Sender.Tell(new ErroredCommandResponse($"Could not complete actor termination due to [{e.Message}]"));
    }
});

This is just an actor await-ing on a GracefulStop, not on its own graceful stop.

Expected behavior

Should not be flagged.

Actual behavior

Is flagged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant