Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-440

Circular dependencies in managed properties lead to StackOverflowError in VariableResolverImpl

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1.1
    • 1.1.0
    • General
    • None
    • N/A

    Description

      Circular dependencies in managed properties lead to java.lang.StackOverflowError in class org.apache.myfaces.el.VariableResolverImpl.

      This can be reproduced with a simple example:
      ... start snippet from faces-config ...

      <managed-bean>
      <managed-bean-name>organisationListController</managed-bean-name>
      <managed-bean-class>nl.ibgroep.demo.web.bean.controller.beheer.OrganisationListController</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
      <managed-property>
      <property-name>organisationDetailsController</property-name>
      <property-class>nl.ibgroep.demo.web.bean.controller.beheer.OrganisationDetailsController</property-class>
      <value>#

      {organisationDetailsController}

      </value>
      </managed-property>
      </managed-bean>

      <managed-bean>
      <managed-bean-name>organisationDetailsController</managed-bean-name>
      <managed-bean-class>nl.ibgroep.demo.web.bean.controller.beheer.OrganisationDetailsController</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
      <managed-property>
      <property-name>organisationListController</property-name>
      <property-class>nl.ibgroep.demo.web.bean.controller.beheer.OrganisationListController</property-class>
      <value>#

      {organisationListController}

      </value>
      </managed-property>
      </managed-bean>

      ... end snippet from faces-config ...

      If I open a page using either of these managed beans, a StackOverflowError error occurs in VariableResolverImpl.

      The reason is that a new managed bean is put in scope after the complete managed bean has been created, including all dependent managed properties. So what happens is that the first managed bean (organisationListController) is created, Subsequently a new bean for its managed property (organisationDetailsController) is created. Because the first bean (organisationListController) was not put in scope, a new managed bean (organisationListController) is created, which leads to the creation of another bean (organisationDetailsController), etc.

      In this simple example the cause is easy to find out, but this will be less so if the circular dependency becomes less obvious.

      Solution: put the bean in scope in the ManagedBeanBuilder, before the recursive creation of its managed properties.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              fbascheper Erik-Berndt Scheper
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: