You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Michael Freedman (JIRA)" <de...@myfaces.apache.org> on 2011/01/25 22:03:43 UTC

[jira] Created: (PORTLETBRIDGE-175) Bridge phase listeners have portlet dependecy but can be executed in a servlet request yielding ClassCastException

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

                 Key: PORTLETBRIDGE-175
                 URL: https://issues.apache.org/jira/browse/PORTLETBRIDGE-175
             Project: MyFaces Portlet Bridge
          Issue Type: Bug
          Components: Impl
    Affects Versions: 2.0.0, 1.0.0, 3.0.0-alpha
            Reporter: Michael Freedman
            Assignee: Michael Freedman


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.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (PORTLETBRIDGE-175) Bridge phase listeners have portlet dependecy but can be executed in a servlet request yielding ClassCastException

Posted by "Michael Freedman (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/PORTLETBRIDGE-175?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Freedman resolved PORTLETBRIDGE-175.
--------------------------------------------

       Resolution: Fixed
    Fix Version/s: 3.0.0-alpha

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

> Bridge phase listeners have portlet dependecy but can be executed in a servlet request yielding ClassCastException
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: PORTLETBRIDGE-175
>                 URL: https://issues.apache.org/jira/browse/PORTLETBRIDGE-175
>             Project: MyFaces Portlet Bridge
>          Issue Type: Bug
>          Components: Impl
>    Affects Versions: 1.0.0, 2.0.0, 3.0.0-alpha
>            Reporter: Michael Freedman
>            Assignee: Michael Freedman
>             Fix For: 3.0.0-alpha
>
>
> 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.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira