You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org> on 2013/09/15 03:12:51 UTC

[jira] [Resolved] (MYFACES-3722) Cache for ResourceHandlerImpl.isResourceRequest seams not to work in 'none resource requests'

     [ https://issues.apache.org/jira/browse/MYFACES-3722?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leonardo Uribe resolved MYFACES-3722.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.1.13
                   2.0.19
         Assignee: Leonardo Uribe

Thanks to Dennis Hoersch for provide this patch
                
> Cache for ResourceHandlerImpl.isResourceRequest seams not to work in 'none resource requests'
> ---------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-3722
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3722
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 2.1.11
>            Reporter: dennis hoersch
>            Assignee: Leonardo Uribe
>             Fix For: 2.0.19, 2.1.13
>
>
> There is a cache for the calculated result whether the given request is a resource request.
> I think it is not working as expected in the moment.
> ResourceHandlerImpl:
>     @Override
>     public boolean isResourceRequest(FacesContext facesContext)
>     {
>         // Since this method could be called many times we save it
>         //on request map so the first time is calculated it remains
>         //alive until the end of the request
>         Boolean value = (Boolean) facesContext.getAttributes().get(IS_RESOURCE_REQUEST);
>         if (value != null && value)
>         {
>             //return the saved value
>             return value;
>         }
>         else
>         {
>             String resourceBasePath = getResourceHandlerSupport()
>                     .calculateResourceBasePath(facesContext);
>             if (resourceBasePath != null
>                     && resourceBasePath.startsWith(ResourceHandler.RESOURCE_IDENTIFIER))
>             {
>                 facesContext.getAttributes().put(IS_RESOURCE_REQUEST, Boolean.TRUE);
>                 return true;
>             }
>             else
>             {
>                 facesContext.getAttributes().put(IS_RESOURCE_REQUEST, Boolean.FALSE);
>                 return false;
>             }
>         }
>     }
> In case of IS_RESOURCE_REQUEST=false the value is recalculated for every method call again because of the 'if (value != null && value)'. I think it just should be 'if (value != null)', or?
> ----
> (
>     @Override
>     public boolean isResourceRequest(FacesContext facesContext)
>     {
>         // Since this method could be called many times we save it
>         // on request map so the first time is calculated it remains
>         // alive until the end of the request
>         Boolean value = (Boolean) facesContext.getAttributes().get(IS_RESOURCE_REQUEST);
>         if (value == null)
>         {
>             String resourceBasePath = getResourceHandlerSupport()
>                     .calculateResourceBasePath(facesContext);
>             value = resourceBasePath != null
>                     && resourceBasePath.startsWith(ResourceHandler.RESOURCE_IDENTIFIER);
>             facesContext.getAttributes().put(IS_RESOURCE_REQUEST, value);
>         }
>         return value;
>     }
> )

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira