IdentityServer4 icon indicating copy to clipboard operation
IdentityServer4 copied to clipboard

ActionDescriptor - Operations that change non-concurrent collections must have exclusive access

Open johnavery opened this issue 7 years ago • 2 comments

I've run into this issue when invoking a custom middleware component used for extracting the user identity from a REST API call. This is happening in our ASP.NET Core 2.1.6 API. This is a similar issue to IdentityServer/IdentityServer4 #2453. The culprit seems to be Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor.Properties. It is being initialized as a Dictionary<object, object>, but it seems you may want to consider a ConcurrentDictionary instead. I've included the exception details. Please let me know what additional information would be helpful.

Exception: System.InvalidOperationException

ExceptionMessage: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.

Stack Trace: at System.Collections.Generic.Dictionary2.FindEntry(TKey key) at System.Collections.Generic.Dictionary2.TryGetValue(TKey key, TValue& value) at Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptorExtensions.GetProperty[T](ActionDescriptor actionDescriptor) at Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptorExtensions.IsImplicitlyMappedTo(ActionDescriptor action, ApiVersion version) at Microsoft.AspNetCore.Mvc.Versioning.ApiVersionActionSelector.ActionIsSatisfiedBy(ActionDescriptor action, ApiVersionModel model, ApiVersion version, ICollection1 implicitMatches) at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Collections.Generic.List1.AddEnumerable(IEnumerable1 enumerable) at System.Collections.Generic.List1.InsertRange(Int32 index, IEnumerable1 collection) at Microsoft.AspNetCore.Mvc.Versioning.ApiVersionActionSelector.SelectBestActions(ActionSelectionContext context) at Microsoft.AspNetCore.Mvc.Versioning.ApiVersionActionSelector.SelectBestCandidate(RouteContext context, IReadOnlyList1 candidates) at Microsoft.AspNetCore.Mvc.Internal.MvcAttributeRouteHandler.RouteAsync(RouteContext context) at Microsoft.AspNetCore.Routing.Tree.TreeRouter.RouteAsync(RouteContext context) at Microsoft.AspNetCore.Routing.RouteCollection.RouteAsync(RouteContext context) at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) at FMGlobal.Lucid.Api.IndexManagement.Middleware.ConfigureUserIdentityInfoMiddleware.Invoke(HttpContext context, IEnvironmentLogic environmentLogic, UserIdentityInfo userIdentityInfo, ILogger1 logger) in C:\agent13\_work\39\s\src\Api.IndexManagement\Middleware\ConfigureUserIdentityInfoMiddleware.cs:line 48 at Lucid.Api.IndexManagement.Middleware.ApiKeyValidatorMiddleware.Invoke(HttpContext context) in C:\agent13\_work\39\s\src\Api.IndexManagement\Middleware\ApiKeyValidatorMiddleware.cs:line 60 at Lucid.Api.IndexManagement.Startup.<>c.<b__15_0>d.MoveNext() in C:\agent13\_work\39\s\src\Api.IndexManagement\Startup.cs:line 516 --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)

johnavery avatar Dec 14 '18 17:12 johnavery

Sorry, I added this issue to the wrong repo. Please disregard.

johnavery avatar Dec 14 '18 17:12 johnavery

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 12 '20 15:01 lock[bot]