dev@javaserverfaces.java.net

Re: Issue 2746

From: Edward Burns <edward.burns_at_oracle.com>
Date: Fri, 13 Sep 2013 15:09:31 -0700

>>>>> On Fri, 13 Sep 2013 12:09:42 -0500, Manfred Riem <manfred.riem_at_oracle.com> said:

MR> Hi all,
MR> Because of issue #2746 I propose an implementation change in UIComponentBase
MR> that makes the static descriptors field a non-static field.

MR> See the JIRA issue for the proposed implementation.

MR> Let me know your thoughts!

In populateDescriptorsMapIfNecessary() you are making the private
descriptors map no longer static. Instead, you are storing it in the
application scope. This is fine in and of itself, but wouldn't you need
to do some sort of two-phase process to initially get access to the map
in that method? Without such protection, your proposed solution seems
open to race conditions.

Because the map is now a ConcurrentHashMap, reads and writes to the map
should be fine. I suggest pre-allocating the map in that place in our
code where we do a bunch of stuff on the PostConstructApplicationEvent.
I think it's in WebConfiguration. This eliminates the possibility of
a race condition in the creation of the COMPONENT_DESCRIPTORS_MAP.

Ed