MyFaces Portlet Bridge
  1. MyFaces Portlet Bridge
  2. PORTLETBRIDGE-175

Bridge phase listeners have portlet dependecy but can be executed in a servlet request yielding ClassCastException

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.0, 2.0.0, 3.0.0-alpha
    • Fix Version/s: 3.0.0-alpha
    • Component/s: Impl
    • Labels:
      None

      Description

      The Bridge temporarily installs its own phase listeners to provide a variety of behaviors . As phase listeners are controlled by the lifecycle and there (can be) is only 1 lifecycle instance per application all listeners are called whenever the lifecycle is run. Because you can have distinct portlets in a application and the application can also run as a servlet care must be taken to only execute the phase listener if its truly the target of the execution. The bridge properly handles this for the multiple portlet case by checking that the event's FacesContext is the same as the thread's (current instances). Unfortunately this doesn't prevent the code from executing in the servlet case. I.e. if a portlet request comes in an is being processed by the bridge it will install the phase listener. If a second request happens concurrently but accesses this app as a servlet, we will execute the bridge's phase listener in this servlet request. This results in a ClassCastException as the code accesses the request object as a PortletRequest (but its not).

      Simple fix is to expand the test to only execute the phase listener is the FacesContext instance match and its a Portlet request.

        Activity

        Hide
        Michael Freedman added a comment -

        As suggested, modified code to ensure we are in a Portlet request before executing phase listener.

        Show
        Michael Freedman added a comment - As suggested, modified code to ensure we are in a Portlet request before executing phase listener.

          People

          • Assignee:
            Michael Freedman
            Reporter:
            Michael Freedman
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development