Skip to content

Commit cfae9f5

Browse files
Merge pull request #1371 from evolvedlight/6.x
Fix #1370 by making copy of default AuthMechanisms
2 parents c582de2 + 4a7f9ee commit cfae9f5

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

projects/RabbitMQ.Client/client/api/ConnectionFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public sealed class ConnectionFactory : ConnectionFactoryBase, IAsyncConnectionF
153153
/// <summary>
154154
/// SASL auth mechanisms to use.
155155
/// </summary>
156-
public IList<IAuthMechanismFactory> AuthMechanisms { get; set; } = DefaultAuthMechanisms;
156+
public IList<IAuthMechanismFactory> AuthMechanisms { get; set; } = DefaultAuthMechanisms.ToList();
157157

158158
/// <summary>
159159
/// Address family used by default.

projects/Unit/TestConnectionFactory.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,5 +279,14 @@ public void TestCreateConnectioUsesValidEndpointWhenMultipleSupplied()
279279
var ep = new AmqpTcpEndpoint("localhost");
280280
using(IConnection conn = cf.CreateConnection(new List<AmqpTcpEndpoint> { invalidEp, ep })) {};
281281
}
282+
283+
[Test]
284+
public void TestCreateConnectionTwiceDoesntClearAuthMechanisms()
285+
{
286+
var cf = new ConnectionFactory();
287+
cf.AuthMechanisms.Clear();
288+
var cf2 = new ConnectionFactory();
289+
Assert.That(cf2.AuthMechanisms.Count, Is.EqualTo(1));
290+
}
282291
}
283292
}

0 commit comments

Comments
 (0)