Well, it /is/ the case that page fields and pages are thread-safe.
But persistent fields are accessing their data from the session, and session-bound data is only thread-safe if you explicitly make it so. You're right, though: the documentation should probably be more clear in that regard, as you pointed out.

Robert

On Jul 13, 2009, at 7/133:21 PM , kristjankelt wrote:


Hi,

After a little thinking about Tapestry persistence, I constructed a sample that shows how Tapestry page field persistence handling is not thread safe.

This is a page class and it's template:

http://www.nabble.com/file/p24468298/NotSafe.java NotSafe.java
http://www.nabble.com/file/p24468298/NotSafe.tml NotSafe.tml

Now when you hit the "update" button more than once in IE (Firefox prevents multiple requests, but remember that this is only client side security) you
will still see value incremented only by one. You will see also in the
console multiple outputs with the same value.

This is so because each request will get it's copy of the counter at the
beginning of the request and will write it back after it finishes
processing.

Alternative would be moving this code into "Setup Render" method and hitting
the refresh button many times - this will work also with Firefox.

I'm writing about this because Tapestry documentation creates sense of false security because it states that Page classes could be written in not thread safe manner (what is true when you do not have persistent fields) but this
statement does not hold in all the cases.

I played with the locks in the session and it kind of worked (you can make another request to wait or raise a exception to indicate duplicate request).

When anyone has more ideas about this problem then I'm more than thankful to
hear about them.

Regards,
Kristjan Kelt
--
View this message in context: 
http://www.nabble.com/T5-Page-field-persistance-and-multithread-problems-tp24468298p24468298.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to