Search code examples
struts2thread-safetyhttprequestvaluestackactioncontext

Is ValueStack container thread-safe?


Action classes are thread-safe since Struts filter creates new action object for each request.

All the action objects along with variables will be stored in ValueStack. So, Is the ValueStack container thread-safe?

Could we able to take values form different action objects of different requests?


Solution

  • It's thread-safe. When an action is instantiated a new ValueStack is created in the ActionContext.

    The ValueStack is actually has a scope action. Everything that falls into it should be resolved by the one of the action instances. Other instances preserve their space for the new incoming variables.