myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Karl Krukow (JIRA)" <>
Subject [jira] Created: (PORTLETBRIDGE-159) Race condition in GenericFacesPortlet: mFacesBridge
Date Fri, 30 Jul 2010 14:13:18 GMT
Race condition in GenericFacesPortlet: mFacesBridge 

                 Key: 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)
        // ensure we only ever create/init one bridge per portlet
          if (mFacesBridge == null)
            mFacesBridge = mFacesBridgeClass.newInstance();
      catch (Exception e)
        throw new PortletException("doBridgeDisptach:  error instantiating the bridge class",

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.

View raw message