You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Nourredine <no...@atos.net> on 2011/09/21 11:31:43 UTC
[Tapestry 5.2] Per-thread scope services not thread safe ?
Hi,
Since Tapestry 5.2, it seems that per-thread scope services are not
thread-safe (some of our integration tests executed in parallel fail since
Tapestry 5.2).
We do not obtain a new instance of the service for each request/thread as
expected.
That leads to strange behaviour when you use the Environmental services as
data's container for example.
I also noticed that the synchronization of some resources (used by
per-thread scope services) is effective only for jdk 1.5 (see
PerthreadmanagerImpl's constructor and JDUtils.JDK_1_5). But this aspect
does not explain everything : the pb occurs with JDK 1.5 too.
Has someone already experimented that pb? should I raise a JIRA? (I can
provide a sample that reproduces the issue)
Nourredine.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-2-Per-thread-scope-services-not-thread-safe-tp4825735p4825735.html
Sent from the Tapestry - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org
Re: [Tapestry 5.2] Per-thread scope services not thread safe ?
Posted by Martin Strand <do...@gmail.com>.
On Thu, 22 Sep 2011 11:03:02 +0200, Nourredine
<no...@atos.net> wrote:
> Thanks to Martin, I realized that my sample was not relevant and that the
> conditioned lock around the holder, in PerthreadManagerImpl, is not a
> problem and maybe, "in the worst case", only redundant.
Indeed, PerThreadServiceCreator somewhat looks like a race bug and might
deserve a comment explaining why it's not:
if (perThreadValue.exists())
return perThreadValue.get();
return perThreadValue.set(delegate.createObject());
Eventhough it's not obvious at a first glance, I believe this really is
thread safe since the ThreadLocal in PerthreadManagerImpl#holder holds the
only mutable object involved here.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org
Re: [Tapestry 5.2] Per-thread scope services not thread safe ?
Posted by Nourredine <no...@atos.net>.
Hi,
Finally, it was a false alarm. See the discussion on the jira :
https://issues.apache.org/jira/browse/TAP5-1660
Thanks to Martin, I realized that my sample was not relevant and that the
conditioned lock around the holder, in PerthreadManagerImpl, is not a
problem and maybe, "in the worst case", only redundant.
My original issue is probably related to a side effect from our code since
the tapestry 5.2 migration (the issue does not occur when the page pool is
enabled).
By the way, it's really a pleasure to read the tapestry source code and
discuss with the community.
Nourredine.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-2-Per-thread-scope-services-not-thread-safe-tp4825735p4829505.html
Sent from the Tapestry - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org
Re: [Tapestry 5.2] Per-thread scope services not thread safe ?
Posted by Nourredine <no...@atos.net>.
The related JIRA : https://issues.apache.org/jira/browse/TAP5-1660
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-2-Per-thread-scope-services-not-thread-safe-tp4825735p4826258.html
Sent from the Tapestry - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org
Re: [Tapestry 5.2] Per-thread scope services not thread safe ?
Posted by Nourredine <no...@atos.net>.
Thiago,
Thanks for answering and clarifying my previous sentence . What I meant is
that , in fine, the proxy is expected to use a new instance of the service
for each thread/request.
I'll raise a jira!
Nourredine.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-2-Per-thread-scope-services-not-thread-safe-tp4825735p4826193.html
Sent from the Tapestry - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org