On Mon, May 21, 2012 at 4:54 AM, Bryan Lewis <[email protected]> wrote:
> I experienced a fourth possibility, although it could be considered a
> variant of the third one.  I was storing an object map (a Cayenne
> ObjectContext) in a ThreadLocal and I wasn't clearing the ThreadLocal
> immediately at the end of each request.  In rare circumstances, when a
> second user started a request at the same time another request ended, the
> second user could see the first one's objects.  App servers (Jetty in my
> case) generally use thread pooling.

You should use the PerthreadManager service, and have it create a
PerThreadValue for you.  The PerThreadValue can be saved and used
across threads, but the value is stored inside a single Map that is
managed by Tapestry and therefore properly cleared at the end of the
request.

http://tapestry.apache.org/5.3.3/apidocs/org/apache/tapestry5/ioc/services/PerthreadManager.html

>
>
>
> On Mon, May 21, 2012 at 5:36 AM, Lance Java <[email protected]>wrote:
>
>> Without seeing any code it's hard to tell but there are only a couple of
>> ways
>> for user A to see user B's data.
>>
>> 1. You have initialized a page/component variable in the field declaration
>> (or the constructor). This is the most likely candidate. Mutable objects
>> MUST NOT be initialized in the field declaration or constructor and must be
>> initialized in onActivate() / beginRender() etc.
>>
>> 2. You have a mutable static variable (almost always a bad idea)
>>
>> 3. You have a mutable variable on a singleton service (again, most of the
>> time this is a bad idea).
>>
>> --
>> View this message in context:
>> http://tapestry.1045711.n5.nabble.com/t5-3-x-Potential-Static-Util-Class-Concurrency-Issue-tp5712809p5712819.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to