Re: Review: Remove synchronized block in Lifecycle.Phase()

From: <>
Date: Thu, 3 Feb 2005 18:48:01 +0100

If a Lifecycle is shared across multiple threads (FacesServlet)....

To be able to use a temporary reference, it requires that the List it
points to is immutable. So the other part of the solution occurs
within the add/remove phase listener. Similar to commons-collection's
FastArrayList implementation (ala Craig), upon mutation, the internal
list is cloned and the clone is mutated, not the original. Once the
cloned version is mutated, then assign it to the internal reference.
This assures that the temporary reference for any given thread will
never change within a process, even if the Lifecycle's listener list
changes for succeeding threads.


Jayashri Visvanathan <Jayashri.Visvanathan_at_Sun.COM> wrote on 02/03/2005,
06:34:52 PM:
> M src/com/sun/faces/lifecycle/
> Fix for bug 6223295. Get a pointer to 'listeners' so that
> we still have reference to the original list for the current
> thread. As a result, any listener added would not show up
> until the NEXT phase but we want to avoid the lengthy
> synchronization block. Due to this, "listeners" should be
> modified only via add/remove methods and must never be updated directly.