You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by robert baker <le...@gmail.com> on 2012/01/05 06:35:53 UTC

[T5.2.6] Component class transformation on initialized private instance fields

Hi all,

When a page/component is transformed (in version 5.2.6) and there is a
field like the following:

private List<TheType> aList = new ArrayList<TheType>();

Does the inline initialization claim the field at transformation-time
so that it is not cleared during request detachment?

("Claim" as in what the @Retain annotation would do in vers. 5.1.0.5 and prior.)

I looked in the online manual for information about this but didn't
find anything in the places I looked, and quickly got over my head
(for the short time I had) in the source.  I'm trying to debug a
problem (data bleeding over into other sessions) with a coworker's
page class and a "yes" answer to the above would complete the circle,
so to speak.

Thanks very much,
Les Baker

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


Re: [T5.2.6] Component class transformation on initialized private instance fields

Posted by Josh Canfield <jo...@gmail.com>.
> Does the inline initialization claim the field at transformation-time
> so that it is not cleared during request detachment?

The inline initialization is used to reset the value at the end of a
request. So, if you put stuff in the default list then you are going
to see it in all of your pages. It's pretty easy to test.

void onActivate() {
  System.out.println("aList.length: " + aList.length());
  aList.add("something");
  // over write it
  aList = new ArrayList();
}
Every time you load the page you should see the length getting bigger.

This may also cause concurrency problems depending on what operations
you are performing on the list since all the requests are using the
same object.

Josh


On Wed, Jan 4, 2012 at 9:35 PM, robert baker <le...@gmail.com> wrote:
> Hi all,
>
> When a page/component is transformed (in version 5.2.6) and there is a
> field like the following:
>
> private List<TheType> aList = new ArrayList<TheType>();
>
> Does the inline initialization claim the field at transformation-time
> so that it is not cleared during request detachment?
>
> ("Claim" as in what the @Retain annotation would do in vers. 5.1.0.5 and prior.)
>
> I looked in the online manual for information about this but didn't
> find anything in the places I looked, and quickly got over my head
> (for the short time I had) in the source.  I'm trying to debug a
> problem (data bleeding over into other sessions) with a coworker's
> page class and a "yes" answer to the above would complete the circle,
> so to speak.
>
> Thanks very much,
> Les Baker
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>

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