dev@javaserverfaces.java.net

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

From: Ed Burns <Ed.Burns_at_Sun.COM>
Date: Thu, 03 Feb 2005 11:28:20 -0800

>>>>> On Thu, 03 Feb 2005 11:17:11 -0800, Jayashri Visvanathan <Jayashri.Visvanathan_at_Sun.COM> said:

JV> Ed suggested cloning the "listeners" in the phase() method instead of
JV> cloning the add/remove method. That way, we also avoid cloning twice.
JV> Here is the modified change bundle. Please review.
JV> Thanks
JV> -Jayashri

JV> Index: src/com/sun/faces/lifecycle/LifecycleImpl.java
JV> ===================================================================
JV> RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/lifecycle/LifecycleImpl.java,v
JV> retrieving revision 1.45.28.1
JV> diff -u -r1.45.28.1 LifecycleImpl.java
JV> --- src/com/sun/faces/lifecycle/LifecycleImpl.java 1 Feb 2005 22:43:53 -0000 1.45.28.1
JV> +++ src/com/sun/faces/lifecycle/LifecycleImpl.java 3 Feb 2005 19:14:00 -0000
JV> @@ -45,7 +45,7 @@
 
 
JV> // The set of PhaseListeners registered with this Lifecycle instance
JV> - private List listeners = new ArrayList();
JV> + private ArrayList listeners = new ArrayList();
 
 
JV> // The set of Phase instances that are executed by the execute() method
JV> @@ -184,23 +184,28 @@
JV> int
JV> i = 0,
JV> maxBefore = 0;
JV> -
JV> + List tempListeners = listeners.clone();

Yes, I think this is sufficient because we don't need to worry about the
list changing underneath us due to someone calling add or remove.

r=edburns

Ed

-- 
| ed.burns_at_sun.com  | {home: 407 294 2468, office: 408 884 9519 OR x31640}
| homepage:         | http://javaweb.sfbay.sun.com/~edburns/
| aim: edburns0sunw | iim: ed.burns_at_sun.com