You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@shale.apache.org by "Matt Hughes (JIRA)" <ji...@apache.org> on 2007/05/01 20:11:42 UTC

[jira] Commented: (SHALE-409) Shale 1.0.4+ incorrectly removes all entries in the request map after render response

    [ https://issues.apache.org/struts/browse/SHALE-409?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_40918 ] 

Matt Hughes commented on SHALE-409:
-----------------------------------

There clearly is a bug in this method.  In the first while block, it finds all keys in the request map whose value is of a certain type.  And then in the second while block, it finds all keys in the map that it hasn't already added before.  Therefore, after the second while block, the 'list' variable has EVERY KEY that was in the original map.  If that is really what you intended, you could have made the method a lot simpler: map.clear().  I would submit a fix for this but I really can't figure out what that second while block is trying to do.  Any ideas?  This bug breaks ajax4jsf as well as any other library expecting their request attributes to stay put.


// In ViewPhaseListener
    private void afterRenderResponse(PhaseEvent event) {

        // Initialize local values we will need
        Map map = event.getFacesContext().getExternalContext().getRequestMap();
        // Remove our list of initialized views explicitly
        map.remove(FacesConstants.VIEWS_INITIALIZED);

        List list = new ArrayList();
        Iterator entries = map.entrySet().iterator();

        // First select all the ViewController and AbstractRequestBean instances
        while (entries.hasNext()) {
            Map.Entry entry = (Map.Entry) entries.next();
            if ((entry.getValue() instanceof ViewController)
             || (entry.getValue() instanceof AbstractRequestBean)) {
                list.add(entry.getKey());
            }
        }

        // Second select all remaining instances, which will include annotated
        // managed beans if Shale Tiger is present
        entries = map.entrySet().iterator();
        while (entries.hasNext()) {
            Map.Entry entry = (Map.Entry) entries.next();
            if (!list.contains(entry.getKey())) {
                list.add(entry.getKey());
            }
        }

        // Iterate through the keys in the specified order, removing the
        // corresponding request scope attribute instances
        Iterator keys = list.iterator();
        while (keys.hasNext()) {
            String key = (String) keys.next();
            try {
                //map.remove(key);
            } catch (Exception e) {
                handleException(event.getFacesContext(), e);
            }
        }
    }

> Shale 1.0.4+ incorrectly removes all entries in the request map after render response
> -------------------------------------------------------------------------------------
>
>                 Key: SHALE-409
>                 URL: https://issues.apache.org/struts/browse/SHALE-409
>             Project: Shale
>          Issue Type: Bug
>          Components: View
>    Affects Versions: 1.0.4, 1.0.5-SNAPSHOT
>         Environment: WinXP, AJAX4JSF-1.0.6+, Shale-1.0.4 (Application, Core, Dialog, Spring, Tiger, View)
>            Reporter: Todd Bush
>
> I found this issue while debugging why Shale-1.0.4 caused AJAX4JSF to stop working.  Within the ViewPhaseListener.afterRenderResponse method, all ViewControllers and AbstractRequestBeans are removed from the request map.  Then a second loop through the request map removes all other entries in an attempt to remove any annotated managed beans.  AJAX4JSF relies on entries in the request map while parsing the outgoing HTML, entries which are removed by this phase listener.  Once I comment out the second request map loop, AJAX4JSF works.  Any other technology which relies on request map entries after render response will have a similar problem with Shale.
> The second loop:
>         entries = map.entrySet().iterator();
>         while (entries.hasNext()) {
>             Map.Entry entry = (Map.Entry) entries.next();
>             if (!list.contains(entry.getKey())) {
>                 list.add(entry.getKey());
>             }
>         }
> PS.  Please ignore my comment below.

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