Thread safety in IWindsorContainer?

158 views
Skip to first unread message

MattFenelon

unread,
May 25, 2011, 10:41:38 AM5/25/11
to Castle Project Users
One of our systems built on top of OpenRasta is falling over with what
looks like a race condition. We are using Castle Windsor 2.1 for IoC,
which is also plugged into OpenRasta. The exceptions (stack trace
below) only occur when our web application starts up under load.

OpenRasta registers some components, with Windsor, on-demand, i.e.
when a component is resolved, if it hasn't been registered already, it
is registered and then resolved. If many requests are served at the
same time, this on-demand registering of components causes exceptions
to be thrown within Windsor.

My question is, are the methods within
IWindsorContainer(WindsorContainer) for registering components meant
to be thread-safe, or should OpenRasta be written to counter for this
lack of thread-safety when registering components?

----
System.ArgumentOutOfRangeException: Specified argument was out of the
range of valid values.
Parameter name: capacity
at
System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument
argument)
at System.Collections.Generic.Dictionary`2..ctor(Int32 capacity,
IEqualityComparer`1 comparer)
at System.Collections.Generic.Dictionary`2..ctor(IDictionary`2
dictionary, IEqualityComparer`1 comparer)
at System.Collections.Generic.Dictionary`2..ctor(IDictionary`2
dictionary)
at
Castle.MicroKernel.Handlers.AbstractHandler.DependencySatisfied(Boolean&
stateChanged)
at
Castle.MicroKernel.DefaultKernel.DoActualRaisingOfHandlersChanged()
at Castle.MicroKernel.DefaultKernel.RaiseHandlersChanged()
at Castle.MicroKernel.DefaultKernel.RegisterHandler(String key,
IHandler handler, Boolean skipRegistration)
at Castle.MicroKernel.DefaultKernel.RegisterHandler(String key,
IHandler handler)
at Castle.MicroKernel.DefaultKernel.AddComponent(String key, Type
serviceType, Type classType, LifestyleType lifestyle, Boolean
overwriteLifestyle)
at Castle.Windsor.WindsorContainer.AddComponentLifeStyle(String
key, Type serviceType, Type classType, LifestyleType lifestyle)
at
OpenRasta.DI.Windsor.WindsorDependencyResolver.AddDependencyCore(Type
dependent, Type concrete, DependencyLifetime lifetime)
at
OpenRasta.DI.Windsor.WindsorDependencyResolver.AddDependencyCore(Type
handlerType, DependencyLifetime lifetime)
at OpenRasta.DI.DependencyResolverCore.AddDependency(Type
concreteType, DependencyLifetime lifetime)
at OpenRasta.DI.DependencyManager.GetService(Type dependencyType)
at
OpenRasta.Pipeline.Contributors.ResponseEntityWriterContributor.WriteResponse(ICommunicationContext
context)
at
OpenRasta.Pipeline.PipelineRunner.ExecuteContributor(ICommunicationContext
context, ContributorCall call)
----

Krzysztof Koźmic

unread,
May 25, 2011, 5:18:04 PM5/25/11
to castle-pro...@googlegroups.com
This does look like a bug,

Can you try to reproduce it with latest version? A test that doesn't
involve open rasta would be more than welcome.

Krzysztof

Reply all
Reply to author
Forward
0 new messages