struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Kiley <jhki...@summa-tech.com>
Subject Re: Interceptors and Thread safety
Date Wed, 08 Jul 2009 13:14:41 GMT
The easiest (I'm not saying best) way to ensure thread safety is to keep
your data in method local variables, rather than in fields on the
interceptor.  Local variables are threadsafe.
jk

On Wed, Jul 8, 2009 at 9:08 AM, ravi_eze <ravichandrac@ivycomptech.com>wrote:

>
> hi,
>
> http://struts.apache.org/2.x/docs/writing-interceptors.html says that
> interceptors are not thread safe, i wanted a deeper understanding on this.
>
> Case:
> 1. Suppose i have 2 action tags each having an interceptor (I) referenced
> in
> it
> 2. 2 action tags with interceptors referenced *twice in each* of them
>
> If interceptors are not thread safe then how many instances of the objects
> are created in the above cases. My common-sense says 2 & 4 objects
> respectively.
>
> Now,
> I have an interceptor which takes data from the struts.xml in the form of
> params tags. The value of these param tags are held in the interceptor
> class's field variables. I have this interceptor included in my struts.xml
> as said in the case1 and 2 above. Now on concurrent requests do i get
> threading issues? Please clarify.
>
> Is it thread safe if i dont put the field variables related to the internal
> processing of the class? i.e.. i have field variables only related to the
> param tags only and nothing more. Now is the interceptor thread safe?
>
> Kindly clarify.
>
>
>
> --
> View this message in context:
> http://www.nabble.com/Interceptors-and-Thread-safety-tp24391223p24391223.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Jim Kiley
Senior Technical Consultant | Summa
[p] 412.258.3346
http://www.summa-tech.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message