Closed
Description
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
- 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