Skip to content

Commit 6a3b2cf

Browse files
authored
Replace AddOrUpdate with GetOrAdd (#915)
1 parent 331f06a commit 6a3b2cf

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-

2-
using System.Collections.Concurrent;
1+
using System.Collections.Concurrent;
32
using EasyNetQ.Topology;
43

54
namespace EasyNetQ.Consumer
65
{
76
public class HandlerCollectionPerQueueFactory : IHandlerCollectionFactory
87
{
9-
readonly ConcurrentDictionary<string, IHandlerCollection> handlerCollections = new ConcurrentDictionary<string, IHandlerCollection>();
8+
private readonly ConcurrentDictionary<string, IHandlerCollection> handlerCollections = new ConcurrentDictionary<string, IHandlerCollection>();
109

1110
public IHandlerCollection CreateHandlerCollection(IQueue queue)
1211
{
13-
return handlerCollections.AddOrUpdate(queue.Name,
14-
queueName => new HandlerCollection(),
15-
(queueName, existingCollection) => existingCollection);
12+
return handlerCollections.GetOrAdd(queue.Name, _ => new HandlerCollection());
1613
}
1714
}
18-
}
15+
}

0 commit comments

Comments
 (0)