Race condition in GenericFacesPortlet: mFacesBridge
----------------------------------------------------
Key: PORTLETBRIDGE-159
URL: https://issues.apache.org/jira/browse/PORTLETBRIDGE-159
Project: MyFaces Portlet Bridge
Issue Type: Bug
Components: API
Reporter: Karl Krukow
Assignee: Michael Freedman
GenericFacesPortlet contains an instance variable of type Bridge
private Bridge mFacesBridge = null;
this is "lazily" initialized in "initBridge" called in "" called in ""
initBridge uses the broken "double checked locking" idiom
private void initBridge() throws PortletException
{
// Ensure te Bridge has been constrcuted and initialized
if (mFacesBridge == null)
{
try
{
// ensure we only ever create/init one bridge per portlet
synchronized(mLock)
{
if (mFacesBridge == null)
{
mFacesBridge = mFacesBridgeClass.newInstance();
mFacesBridge.init(getPortletConfig());
}
}
}
catch (Exception e)
{
throw new PortletException("doBridgeDisptach: error instantiating the
bridge class", e);
}
}
}
On Java 1.5+ this can be made safe by changing the declaration to:
private volatile Bridge mFacesBridge = null;
at a small synchronization cost. Alternatively consider if a version of Josh
Bloch's static initialization "on demand" could be used
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.