You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Igor Vaynberg (JIRA)" <ji...@apache.org> on 2010/08/26 00:15:18 UTC

[jira] Resolved: (WICKET-1821) WebRequestCodingStrategy assumes mount path prefix for matching

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

Igor Vaynberg resolved WICKET-1821.
-----------------------------------

         Assignee: Igor Vaynberg
    Fix Version/s: 1.5-M1
                       (was: 1.5-M2)
       Resolution: Fixed

> WebRequestCodingStrategy assumes mount path prefix for matching
> ---------------------------------------------------------------
>
>                 Key: WICKET-1821
>                 URL: https://issues.apache.org/jira/browse/WICKET-1821
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.4-M1, 1.4-M2, 1.4-M3
>         Environment: Linux (openSUSE 10.2 and 11.0), x86_64, jetty; but affects all environments
>            Reporter: Pascal Bleser
>            Assignee: Igor Vaynberg
>            Priority: Minor
>             Fix For: 1.5-M1
>
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> WebRequestCodingStrategy makes an assumption about IRequestTargetUrlCodingStrategy implementations in what seems to be a minor optimization:
> in WebRequestCodingStrategy.MountsMap.strategyForPath:
> for (Entry<String, IRequestTargetUrlCodingStrategy> entry : map.entrySet())
> {
>    final String key = entry.getKey();
>    if (path.startsWith(key))
>    {
>       IRequestTargetUrlCodingStrategy strategy = entry.getValue();
>       if (strategy.matches(path))
>       {
>          return strategy;
>       }
>    }
> }
> While it should actually be the following instead:
> for (IRequestTargetUrlCodingStrategy strategy : listMounts()) {
>    if ((strategy != null) && strategy.matches(path)) {
>       return strategy;
>    }
> }
> I ran into that issue while implementing a custom IRequestTargetUrlCodingStrategy that uses a pattern based approach, e.g. for an URL like this:
> /customer/1000/site/100/edit
> It is mounted with the following String:
> "/customer/${customerId}/site/${siteId}/edit"
> but it is simply skipped by WebRequestCodingStrategy.MountsMap.strategyForPath() because the mount prefix doesn't match (as in a simple String.startsWith(), as performed by strategyForPath()), while only calling match(String) on the IRequestTargetUrlCodingStrategy works, because match(String) is implemented accordingly in the custom IRequestTargetUrlCodingStrategy.
> I would consider this to be a bug, because the current implementation in WebRequestCodingStrategy.MountsMap.strategyForPath() assumes that all IRequestTargetUrlCodingStrategy have a fixed prefix that can be matched using String.startsWith(), while that isn't necessarily the case.

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