Skip to content

XmlNamespaceManager corruption #743

@andersjonsson

Description

@andersjonsson

When testing things on our servers I got this exception:

System.InvalidOperationException: 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.
   at System.Collections.Generic.Dictionary<TKey,TValue>.FindValue(TKey key)
   at System.Collections.Generic.Dictionary<TKey,TValue>.TryGetValue(TKey key, TValue& value)
   at System.Xml.XmlNamespaceManager.LookupNamespaceDecl(String prefix)
   at System.Xml.XmlNamespaceManager.LookupNamespace(String prefix)
   at System.Xml.XmlNamespaceManager.LookupPrefix(String uri)
   at SoapCore.Namespaces.AddNamespaceIfNotAlreadyPresentAndGetPrefix(XmlNamespaceManager xmlNamespaceManager, String preferredPrefix, String uri)
   at SoapCore.Namespaces.AddDefaultNamespaces(XmlNamespaceManager xmlNamespaceManager)
   at SoapCore.SoapEndpointMiddleware<T>.GetXmlNamespaceManager()
   at SoapCore.SoapEndpointMiddleware<T>.ProcessMeta(HttpContext httpContext)
   at SoapCore.SoapEndpointMiddleware<T>.Invoke(HttpContext httpContext, IServiceProvider serviceProvider)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at legaonline.apiws.Startup.<>c.<<Configure>b__4_0>d.MoveNext() in Startup.cs:line 112
--- End of stack trace from previous location ---
   at StackExchange.Exceptional.ExceptionalMiddleware.Invoke(HttpContext context)

I see that this kind of error has been encountered before and that a PR has been merged #693 but obviously it can still happen, if multiple people access the endpoint before the XmlNamespaceManager has been fully populated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions