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

NullReferenceException on AutorecoveringModel.IsClosed #829

Closed
ig-sinicyn opened this issue May 10, 2020 · 7 comments · Fixed by #832
Closed

NullReferenceException on AutorecoveringModel.IsClosed #829

ig-sinicyn opened this issue May 10, 2020 · 7 comments · Fixed by #832
Assignees
Milestone

Comments

@ig-sinicyn
Copy link
Contributor

RabbitMQ.Client 6.0.0, RabbitMQ.Client.Impl.AutorecoveringModel:

        public bool IsClosed
        {
            get { return _delegate.IsClosed; }
        }

The getter throws null reference for disposed entities. Reason is here:

        private void Dispose(bool disposing)
        {
            if (disposing)
            {
               ...
                _delegate = null;
            }
        }
@lukebakken
Copy link
Contributor

This should be a simple fix, please submit a pull request with a test. Thank you.

@lukebakken lukebakken self-assigned this May 11, 2020
@lukebakken lukebakken added this to the 6.1.0 milestone May 11, 2020
@bording
Copy link
Collaborator

bording commented May 11, 2020

The question is, what is the correct behavior? If the object is disposed, should that return true or false?

Or should it throw ObjectDisposedException?

@ig-sinicyn
Copy link
Contributor Author

I'd prefer following behavior:

  1. For members that are used to check for connection availability/health - do not throw.
    As far as I can see there are only two properties that should not throw:
    IsOpen (returns false if disposed);
    IsClosed (returns true if disposed).
  2. For all other members: throw ObjectDisposedException.

@ig-sinicyn
Copy link
Contributor Author

@lukebakken I'm quite busy this week so the issue is up for grabs:)

@michaelklishin
Copy link
Member

It would be slightly more user-friendly if IsOpen and IsClosed continued acting like predicates and did not throw when the underlying non-recovering connection is disposed of.

@stebet
Copy link
Contributor

stebet commented May 11, 2020

Yep. Throwing in Property Getters is considered bad practice.

@lukebakken
Copy link
Contributor

I'm getting this today.

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.

5 participants