Note that there are some explanatory texts on larger screens.

plurals
  1. POAre Interceptors in Struts2 Thread UNsafe?
    primarykey
    data
    text
    <p>I understand that Struts2 Action classes are thread-safe, because the actions are put in the Value Stack. The Value Stack in turn is one part of the Action Context. Since the Action Context is thread-local, the values stored in the Action Context (including the value stack) are unique per thread. So, Actions are thread-safe.</p> <p>But consider the interceptors: They are really useful, they do all those tedious little jobs for the programmer... like validations, fetching the param values, etc. But the thing to consider is that: Interceptors can be shared between multiple requests. So does that make interceptors thread unsafe?</p> <p>With this question in mind, I tried to surf the net for some good articles related to this problem. And I found a very good article, where they have clearly mentioned with an example How interceptors are NOT thread safe.</p> <p>The web page is: <a href="http://www.bullraider.com/java/struts2/tutorials/interceptors-and-thread-safety">http://www.bullraider.com/java/struts2/tutorials/interceptors-and-thread-safety</a></p> <p>What I got to know from this article is, the major reason behind Interceptors being thread un-safe is that the interceptors are created only once. i.e. each interceptor has only one object. So, the instance fields are not safe, when the <em>same instance</em> of an Interceptor is shared between threads.</p> <p>At the end of the article it's mentioned that there are cases, where even the interceptors are thread safe. But they didn't mentioned any such cases. I surfed the net to find the answer... but in vain :(</p> <p><strong>Can anybody tell me or provide me with a link, where I can find out how to make interceptors thread-safe (or what are the scenarios when an interceptor is thread safe)?</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload