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

ConnectionFactory Authmechanisms has incorrect sharing between instances #1370

Closed
evolvedlight opened this issue Aug 10, 2023 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@evolvedlight
Copy link

Describe the bug

if you connect to two RabbitMq instances, one with EXTERNAL auth, one plain, and change the Auth Mechanisms, the instances change each other.

Reproduction steps

  1. Create new project with rabbitmq client dependency (latest version)
    Paste the following:
ConnectionFactory factory = new ConnectionFactory();
factory.AuthMechanisms.Clear();
ConnectionFactory factory2 = new ConnectionFactory();
Console.WriteLine(factory2.AuthMechanisms.Count);

Expected behavior

I expect to have a single Plain Auth mechanism
Instead I have Zero auth mechanisms

Additional context

It's because the DefaultAuthMechanisms is referenced by reference rather than making a copy of it.
This bug is triggered by MassTransit: https://github.com/MassTransit/MassTransit/blob/15c44ca0c26e9dfcedbdf3e770621c5f3ceb6975/src/Transports/MassTransit.RabbitMqTransport/RabbitMqTransport/RabbitMqAddressExtensions.cs#L65

@evolvedlight
Copy link
Author

I plan to open a PR for this on the weekend, let me know if you don't consider this a bug.

@lukebakken
Copy link
Contributor

lukebakken commented Aug 11, 2023

Good catch! Thank you for reporting this. A PR is very welcome. If you'd like to base it on the 6.x branch I will then forward-merge your changes. main has diverged quite a bit.

@lukebakken lukebakken added this to the 6.6.0 milestone Aug 11, 2023
@lukebakken lukebakken self-assigned this Aug 11, 2023
evolvedlight added a commit to evolvedlight/rabbitmq-dotnet-client that referenced this issue Aug 11, 2023
michaelklishin added a commit that referenced this issue Aug 12, 2023
Fix #1370 by making copy of default AuthMechanisms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants