While doing some multi-threaded batch processing using B2.NET I would sporadically get an Duplicate Key exception from the underlying System.Net.HttpClient during startup.
I traced it back to how the singleton HttpClient is being constructed.
If the stairs align just right it is currently possible that two threads try to add the system Accept request header at the same time (resulting in the previously mentioned exception).
I have added a simple fix in this pull request by privately creating and configuring the HttpClient before sharing it with the rest of the AppDomain.
While doing some multi-threaded batch processing using B2.NET I would sporadically get an Duplicate Key exception from the underlying System.Net.HttpClient during startup.
I traced it back to how the singleton HttpClient is being constructed. If the stairs align just right it is currently possible that two threads try to add the system Accept request header at the same time (resulting in the previously mentioned exception).
I have added a simple fix in this pull request by privately creating and configuring the HttpClient before sharing it with the rest of the AppDomain.