JustinCanton / Geo.NET

A lightweight method for communicating with the multiple online geocoding APIs.
MIT License
13 stars 8 forks source link

Concurrency issue when creating a resource provider #70

Closed JustinCanton closed 1 year ago

JustinCanton commented 1 year ago

Describe the bug It seems like there is a concurrency issue when creating a resource provider in the services. It doesn't seem to happen often, as it has only happened once in all of the builds.

To Reproduce It is a random error, that I cannot reproduce. It has only happened in one build.

  Failed Geo.MapQuest.Tests.Services.MapQuestGeocodingShould.ReverseGeocodingAsyncSuccessfully [231 ms]
  Error Message:
   System.ArgumentException : The key already existed in the dictionary.
  Stack Trace:
     at System.Collections.Concurrent.ConcurrentDictionary`2.System.Collections.Generic.IDictionary<TKey,TValue>.Add(TKey key, TValue value)
   at Geo.Core.GeoNETResourceStringProviderFactory.CreateResourceStringProvider(String resourceFileName, Assembly assembly) in /home/runner/work/Geo.NET/Geo.NET/src/Geo.Core/GeoNETResourceStringProviderFactory.cs:line 54
   at Geo.Core.GeoNETResourceStringProviderFactory.CreateResourceStringProvider(Type resourceType) in /home/runner/work/Geo.NET/Geo.NET/src/Geo.Core/GeoNETResourceStringProviderFactory.cs:line 35
   at Geo.Core.GeoNETResourceStringProviderFactory.CreateResourceStringProvider[TResource]() in /home/runner/work/Geo.NET/Geo.NET/src/Geo.Core/GeoNETResourceStringProviderFactory.cs:line 24
   at Geo.Core.ClientExecutor..ctor(HttpClient client, IGeoNETExceptionProvider exceptionProvider, IGeoNETResourceStringProviderFactory resourceStringProviderFactory, ILoggerFactory loggerFactory) in /home/runner/work/Geo.NET/Geo.NET/src/Geo.Core/ClientExecutor.cs:line 43
   at Geo.MapQuest.Services.MapQuestGeocoding..ctor(HttpClient client, IMapQuestKeyContainer keyContainer, IMapQuestEndpoint endpoint, IGeoNETExceptionProvider exceptionProvider, IGeoNETResourceStringProviderFactory resourceStringProviderFactory, ILoggerFactory loggerFactory) in /home/runner/work/Geo.NET/Geo.NET/src/Geo.MapQuest/Services/MapQuestGeocoding.cs:line 54
   at Geo.MapQuest.Tests.Services.MapQuestGeocodingShould.BuildService(MapQuestEndpoint endpoint) in /home/runner/work/Geo.NET/Geo.NET/test/Geo.MapQuest.Tests/Services/MapQuestGeocodingShould.cs:line 526
   at Geo.MapQuest.Tests.Services.MapQuestGeocodingShould.ReverseGeocodingAsyncSuccessfully() in /home/runner/work/Geo.NET/Geo.NET/test/Geo.MapQuest.Tests/Services/MapQuestGeocodingShould.cs:line 473
--- End of stack trace from previous location where exception was thrown ---

Expected behavior The code should successfully create the resource even in a concurrent environment.