Struts object pooling for subclasses of Action
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ryan_Wynn
Posted On:   Thursday, September 26, 2002 12:20 PM

How does Struts manage to avoid request conflicts when it reuses instances of Action objects? From the code I have seen Struts uses a FastHashMap to store and reuse instances of Action objects; however, I can't understand how when the perform method is called by two threads simultaneously on the same Action instance, conflicts do not arise - specifically with the HttpServletRequest parameter which would potentially be unique to the thread. perform is not synchronized to my knowledge, either in a synchronized block or in the method declaration. I would assume that if two threads requested the same Action object at the same time, one user could potentially get the session of another if request   More>>


How does Struts manage to avoid request conflicts when it reuses instances of Action objects?


From the code I have seen Struts uses a FastHashMap to store and reuse instances of Action objects; however, I can't understand how when the perform method is called by two threads simultaneously on the same Action instance, conflicts do not arise - specifically with the HttpServletRequest parameter which would potentially be unique to the thread. perform is not synchronized to my knowledge, either in a synchronized block or in the method declaration.


I would assume that if two threads requested the same Action object at the same time, one user could potentially get the session of another if request.getSession is called within perform .

   <<Less

Re: Struts object pooling for subclasses of Action

Posted By:   Ryan_Wynn  
Posted On:   Thursday, September 26, 2002 12:30 PM

I just found the answer to my question. Method parameters seem to be protected from simultaneous thread access because they reside on the call stack. Only private member and class variable access needs to be synchronized because these variables are stored in the heap.

If I am wrong let me know.
About | Sitemap | Contact