You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Tsutomu YANO (Created) (JIRA)" <ji...@apache.org> on 2012/02/07 09:56:59 UTC

[jira] [Created] (WICKET-4390) MarkupParser#add(IMarkupFilter filter,Class beforeFilter) doesn't add the filter into the correct place.

MarkupParser#add(IMarkupFilter filter,Class beforeFilter) doesn't add the filter into the correct place.
--------------------------------------------------------------------------------------------------------

                 Key: WICKET-4390
                 URL: https://issues.apache.org/jira/browse/WICKET-4390
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.5.4, 6.0.0
         Environment: any platform
            Reporter: Tsutomu YANO
            Priority: Minor


The documentation comment of MarkupParser#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) says that 'filter' will be added before the 'beforeFilter', but the filter passed is always added as the last element of MarkupList.

Technically, MarkupParser#add() internally uses an inner-class MarkupFilterList for managing filters. But the MarkupFilterList#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) does not implemented correctly.

The method uses 'indexOf' of ArrayList for finding the matched instance of IMarkupFilter, though the parameter is not an instance of IMarkupFilter, but <? extends IMarkupFilter> beforeFilter).

We must iterate all registered IMarkupFilters and check if the Class of the IMarkupFilter matches with the parameter Class object for finding the index of 'beforeFilter'.


** HOW TO REPRODUCE

Unpack, build and run the attached project 'wicket-bug.tar.gz'. 
jp.javelindev.wicket.MyMarkupFactory will log all registered filters with source below:

<pre>
    @Override
    public MarkupParser newMarkupParser(MarkupResourceStream resource) {
        MarkupParser parser = super.newMarkupParser(resource);
        parser.add(new MyMarkupFilter(), WicketTagIdentifier.class);
        parser.add(new MyMarkupFilter2());

        for (IMarkupFilter filter : parser.getMarkupFilters()) {
            LOGGER.info("filter class: {}", filter.getClass());
        }

        return parser;
    }
</pre>

If MarkupParser add filters at correct place, 

- MyMarkupFilter must be displayed at first (because WicketTagIdentifier is the first filter in default implementation) and 
- MyMarkupFilter2 must be displayed before RelativePathPrefixHandler (because the default implementation of add() of MarkupFilterList is like 'add(filter, RelativePathPrefixHandler.class)').

But with trunk and wicket-1.5.4, both filters is displayed at last.

** WORK AROUND **

I can avoid this issue by getting raw MarkupFilterList through getMarkupFilters() and writing code manually to find correct place for add().

** PATCH **

I attached a patch to fix this issue. see the source of MarkupParser.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (WICKET-4390) MarkupParser#add(IMarkupFilter filter,Class beforeFilter) doesn't add the filter into the correct place.

Posted by "Tsutomu YANO (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-4390?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tsutomu YANO updated WICKET-4390:
---------------------------------

    Description: 
The documentation comment of MarkupParser#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) says that 'filter' will be added before the 'beforeFilter', but the filter passed is always added as the last element of MarkupFilterList.

Technically, MarkupParser#add() internally uses an inner-class MarkupFilterList for managing filters. But the MarkupFilterList#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) does not implemented correctly.

The method uses 'indexOf' of ArrayList for finding the matched instance of IMarkupFilter, though the parameter is not an instance of IMarkupFilter, but <? extends IMarkupFilter> beforeFilter).

We must iterate all registered IMarkupFilters and check if the Class of the IMarkupFilter matches with the parameter Class object for finding the index of 'beforeFilter'.


** HOW TO REPRODUCE

Unpack, build and run the attached project 'wicket-bug.tar.gz'. 
jp.javelindev.wicket.MyMarkupFactory will log all registered filters with source below:

<pre>
    @Override
    public MarkupParser newMarkupParser(MarkupResourceStream resource) {
        MarkupParser parser = super.newMarkupParser(resource);
        parser.add(new MyMarkupFilter(), WicketTagIdentifier.class);
        parser.add(new MyMarkupFilter2());

        for (IMarkupFilter filter : parser.getMarkupFilters()) {
            LOGGER.info("filter class: {}", filter.getClass());
        }

        return parser;
    }
</pre>

If MarkupParser add filters at correct place, 

- MyMarkupFilter must be displayed at first (because WicketTagIdentifier is the first filter in default implementation) and 
- MyMarkupFilter2 must be displayed before RelativePathPrefixHandler (because the default implementation of add() of MarkupFilterList is like 'add(filter, RelativePathPrefixHandler.class)').

But with trunk and wicket-1.5.4, both filters is displayed at last.

** WORK AROUND **

I can avoid this issue by getting raw MarkupFilterList through getMarkupFilters() and writing code manually to find correct place for add().

** PATCH **

I attached a patch to fix this issue. see the source of MarkupParser.


  was:
The documentation comment of MarkupParser#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) says that 'filter' will be added before the 'beforeFilter', but the filter passed is always added as the last element of MarkupList.

Technically, MarkupParser#add() internally uses an inner-class MarkupFilterList for managing filters. But the MarkupFilterList#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) does not implemented correctly.

The method uses 'indexOf' of ArrayList for finding the matched instance of IMarkupFilter, though the parameter is not an instance of IMarkupFilter, but <? extends IMarkupFilter> beforeFilter).

We must iterate all registered IMarkupFilters and check if the Class of the IMarkupFilter matches with the parameter Class object for finding the index of 'beforeFilter'.


** HOW TO REPRODUCE

Unpack, build and run the attached project 'wicket-bug.tar.gz'. 
jp.javelindev.wicket.MyMarkupFactory will log all registered filters with source below:

<pre>
    @Override
    public MarkupParser newMarkupParser(MarkupResourceStream resource) {
        MarkupParser parser = super.newMarkupParser(resource);
        parser.add(new MyMarkupFilter(), WicketTagIdentifier.class);
        parser.add(new MyMarkupFilter2());

        for (IMarkupFilter filter : parser.getMarkupFilters()) {
            LOGGER.info("filter class: {}", filter.getClass());
        }

        return parser;
    }
</pre>

If MarkupParser add filters at correct place, 

- MyMarkupFilter must be displayed at first (because WicketTagIdentifier is the first filter in default implementation) and 
- MyMarkupFilter2 must be displayed before RelativePathPrefixHandler (because the default implementation of add() of MarkupFilterList is like 'add(filter, RelativePathPrefixHandler.class)').

But with trunk and wicket-1.5.4, both filters is displayed at last.

** WORK AROUND **

I can avoid this issue by getting raw MarkupFilterList through getMarkupFilters() and writing code manually to find correct place for add().

** PATCH **

I attached a patch to fix this issue. see the source of MarkupParser.


    
> MarkupParser#add(IMarkupFilter filter,Class beforeFilter) doesn't add the filter into the correct place.
> --------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-4390
>                 URL: https://issues.apache.org/jira/browse/WICKET-4390
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.4, 6.0.0
>         Environment: any platform
>            Reporter: Tsutomu YANO
>            Priority: Minor
>         Attachments: fix-WICKET-4390.patch, wicket-bug.tar.gz
>
>
> The documentation comment of MarkupParser#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) says that 'filter' will be added before the 'beforeFilter', but the filter passed is always added as the last element of MarkupFilterList.
> Technically, MarkupParser#add() internally uses an inner-class MarkupFilterList for managing filters. But the MarkupFilterList#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) does not implemented correctly.
> The method uses 'indexOf' of ArrayList for finding the matched instance of IMarkupFilter, though the parameter is not an instance of IMarkupFilter, but <? extends IMarkupFilter> beforeFilter).
> We must iterate all registered IMarkupFilters and check if the Class of the IMarkupFilter matches with the parameter Class object for finding the index of 'beforeFilter'.
> ** HOW TO REPRODUCE
> Unpack, build and run the attached project 'wicket-bug.tar.gz'. 
> jp.javelindev.wicket.MyMarkupFactory will log all registered filters with source below:
> <pre>
>     @Override
>     public MarkupParser newMarkupParser(MarkupResourceStream resource) {
>         MarkupParser parser = super.newMarkupParser(resource);
>         parser.add(new MyMarkupFilter(), WicketTagIdentifier.class);
>         parser.add(new MyMarkupFilter2());
>         for (IMarkupFilter filter : parser.getMarkupFilters()) {
>             LOGGER.info("filter class: {}", filter.getClass());
>         }
>         return parser;
>     }
> </pre>
> If MarkupParser add filters at correct place, 
> - MyMarkupFilter must be displayed at first (because WicketTagIdentifier is the first filter in default implementation) and 
> - MyMarkupFilter2 must be displayed before RelativePathPrefixHandler (because the default implementation of add() of MarkupFilterList is like 'add(filter, RelativePathPrefixHandler.class)').
> But with trunk and wicket-1.5.4, both filters is displayed at last.
> ** WORK AROUND **
> I can avoid this issue by getting raw MarkupFilterList through getMarkupFilters() and writing code manually to find correct place for add().
> ** PATCH **
> I attached a patch to fix this issue. see the source of MarkupParser.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WICKET-4390) MarkupParser#add(IMarkupFilter filter,Class beforeFilter) doesn't add the filter into the correct place.

Posted by "Martin Grigorov (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-4390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13204495#comment-13204495 ] 

Martin Grigorov commented on WICKET-4390:
-----------------------------------------

Some notes:
StyleAndScriptIdentifier markup filter should be added *after* RelativePathPrefixHandler because otherwise the latter overrides the (auto-)component's id and later HeaderPartContainer cannot find its child with id '_ScriptStyle' and thus doesn't execute its onComponentTag and as a result RelativePathPrefixHandler.RELATIVE_PATH_BEHAVIOR doesn't do its job for header contributions coming from <wicket:head> (see MarkupHeadFirstTest).
                
> MarkupParser#add(IMarkupFilter filter,Class beforeFilter) doesn't add the filter into the correct place.
> --------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-4390
>                 URL: https://issues.apache.org/jira/browse/WICKET-4390
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.4, 6.0.0
>         Environment: any platform
>            Reporter: Tsutomu YANO
>            Assignee: Martin Grigorov
>            Priority: Minor
>             Fix For: 1.5.5, 6.0.0
>
>         Attachments: fix-WICKET-4390.patch, wicket-bug.tar.gz
>
>
> The documentation comment of MarkupParser#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) says that 'filter' will be added before the 'beforeFilter', but the filter passed is always added as the last element of MarkupFilterList.
> Technically, MarkupParser#add() internally uses an inner-class MarkupFilterList for managing filters. But the MarkupFilterList#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) does not implemented correctly.
> The method uses 'indexOf' of ArrayList for finding the matched instance of IMarkupFilter, though the parameter is not an instance of IMarkupFilter, but a Class<? extends IMarkupFilter>.
> We must iterate all registered IMarkupFilters and check if the Class of the IMarkupFilter matches with the parameter Class object for finding the index of 'beforeFilter'.
> ** HOW TO REPRODUCE
> Unpack, build and run the attached project 'wicket-bug.tar.gz'. 
> jp.javelindev.wicket.MyMarkupFactory will log all registered filters with source below:
> <pre>
>     @Override
>     public MarkupParser newMarkupParser(MarkupResourceStream resource) {
>         MarkupParser parser = super.newMarkupParser(resource);
>         parser.add(new MyMarkupFilter(), WicketTagIdentifier.class);
>         parser.add(new MyMarkupFilter2());
>         for (IMarkupFilter filter : parser.getMarkupFilters()) {
>             LOGGER.info("filter class: {}", filter.getClass());
>         }
>         return parser;
>     }
> </pre>
> If MarkupParser add filters at correct place, 
> - MyMarkupFilter must be displayed at first (because WicketTagIdentifier is the first filter in default implementation) and 
> - MyMarkupFilter2 must be displayed before RelativePathPrefixHandler (because the default implementation of add() of MarkupFilterList is like 'add(filter, RelativePathPrefixHandler.class)').
> But with trunk and wicket-1.5.4, both filters is displayed at last.
> ** WORK AROUND **
> I can avoid this issue by getting raw MarkupFilterList through getMarkupFilters() and writing code manually to find correct place for add().
> ** PATCH **
> I attached a patch to fix this issue. see the source of MarkupParser.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (WICKET-4390) MarkupParser#add(IMarkupFilter filter,Class beforeFilter) doesn't add the filter into the correct place.

Posted by "Martin Grigorov (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-4390?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Grigorov resolved WICKET-4390.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 6.0.0
                   1.5.5
         Assignee: Martin Grigorov

Fixed!
Thanks!
                
> MarkupParser#add(IMarkupFilter filter,Class beforeFilter) doesn't add the filter into the correct place.
> --------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-4390
>                 URL: https://issues.apache.org/jira/browse/WICKET-4390
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.4, 6.0.0
>         Environment: any platform
>            Reporter: Tsutomu YANO
>            Assignee: Martin Grigorov
>            Priority: Minor
>             Fix For: 1.5.5, 6.0.0
>
>         Attachments: fix-WICKET-4390.patch, wicket-bug.tar.gz
>
>
> The documentation comment of MarkupParser#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) says that 'filter' will be added before the 'beforeFilter', but the filter passed is always added as the last element of MarkupFilterList.
> Technically, MarkupParser#add() internally uses an inner-class MarkupFilterList for managing filters. But the MarkupFilterList#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) does not implemented correctly.
> The method uses 'indexOf' of ArrayList for finding the matched instance of IMarkupFilter, though the parameter is not an instance of IMarkupFilter, but a Class<? extends IMarkupFilter>.
> We must iterate all registered IMarkupFilters and check if the Class of the IMarkupFilter matches with the parameter Class object for finding the index of 'beforeFilter'.
> ** HOW TO REPRODUCE
> Unpack, build and run the attached project 'wicket-bug.tar.gz'. 
> jp.javelindev.wicket.MyMarkupFactory will log all registered filters with source below:
> <pre>
>     @Override
>     public MarkupParser newMarkupParser(MarkupResourceStream resource) {
>         MarkupParser parser = super.newMarkupParser(resource);
>         parser.add(new MyMarkupFilter(), WicketTagIdentifier.class);
>         parser.add(new MyMarkupFilter2());
>         for (IMarkupFilter filter : parser.getMarkupFilters()) {
>             LOGGER.info("filter class: {}", filter.getClass());
>         }
>         return parser;
>     }
> </pre>
> If MarkupParser add filters at correct place, 
> - MyMarkupFilter must be displayed at first (because WicketTagIdentifier is the first filter in default implementation) and 
> - MyMarkupFilter2 must be displayed before RelativePathPrefixHandler (because the default implementation of add() of MarkupFilterList is like 'add(filter, RelativePathPrefixHandler.class)').
> But with trunk and wicket-1.5.4, both filters is displayed at last.
> ** WORK AROUND **
> I can avoid this issue by getting raw MarkupFilterList through getMarkupFilters() and writing code manually to find correct place for add().
> ** PATCH **
> I attached a patch to fix this issue. see the source of MarkupParser.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (WICKET-4390) MarkupParser#add(IMarkupFilter filter,Class beforeFilter) doesn't add the filter into the correct place.

Posted by "Tsutomu YANO (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-4390?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tsutomu YANO updated WICKET-4390:
---------------------------------

    Attachment: fix-WICKET-4390.patch
                wicket-bug.tar.gz

a project for preproduction this issue and a patch.
                
> MarkupParser#add(IMarkupFilter filter,Class beforeFilter) doesn't add the filter into the correct place.
> --------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-4390
>                 URL: https://issues.apache.org/jira/browse/WICKET-4390
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.4, 6.0.0
>         Environment: any platform
>            Reporter: Tsutomu YANO
>            Priority: Minor
>         Attachments: fix-WICKET-4390.patch, wicket-bug.tar.gz
>
>
> The documentation comment of MarkupParser#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) says that 'filter' will be added before the 'beforeFilter', but the filter passed is always added as the last element of MarkupList.
> Technically, MarkupParser#add() internally uses an inner-class MarkupFilterList for managing filters. But the MarkupFilterList#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) does not implemented correctly.
> The method uses 'indexOf' of ArrayList for finding the matched instance of IMarkupFilter, though the parameter is not an instance of IMarkupFilter, but <? extends IMarkupFilter> beforeFilter).
> We must iterate all registered IMarkupFilters and check if the Class of the IMarkupFilter matches with the parameter Class object for finding the index of 'beforeFilter'.
> ** HOW TO REPRODUCE
> Unpack, build and run the attached project 'wicket-bug.tar.gz'. 
> jp.javelindev.wicket.MyMarkupFactory will log all registered filters with source below:
> <pre>
>     @Override
>     public MarkupParser newMarkupParser(MarkupResourceStream resource) {
>         MarkupParser parser = super.newMarkupParser(resource);
>         parser.add(new MyMarkupFilter(), WicketTagIdentifier.class);
>         parser.add(new MyMarkupFilter2());
>         for (IMarkupFilter filter : parser.getMarkupFilters()) {
>             LOGGER.info("filter class: {}", filter.getClass());
>         }
>         return parser;
>     }
> </pre>
> If MarkupParser add filters at correct place, 
> - MyMarkupFilter must be displayed at first (because WicketTagIdentifier is the first filter in default implementation) and 
> - MyMarkupFilter2 must be displayed before RelativePathPrefixHandler (because the default implementation of add() of MarkupFilterList is like 'add(filter, RelativePathPrefixHandler.class)').
> But with trunk and wicket-1.5.4, both filters is displayed at last.
> ** WORK AROUND **
> I can avoid this issue by getting raw MarkupFilterList through getMarkupFilters() and writing code manually to find correct place for add().
> ** PATCH **
> I attached a patch to fix this issue. see the source of MarkupParser.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (WICKET-4390) MarkupParser#add(IMarkupFilter filter,Class beforeFilter) doesn't add the filter into the correct place.

Posted by "Tsutomu YANO (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-4390?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tsutomu YANO updated WICKET-4390:
---------------------------------

    Description: 
The documentation comment of MarkupParser#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) says that 'filter' will be added before the 'beforeFilter', but the filter passed is always added as the last element of MarkupFilterList.

Technically, MarkupParser#add() internally uses an inner-class MarkupFilterList for managing filters. But the MarkupFilterList#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) does not implemented correctly.

The method uses 'indexOf' of ArrayList for finding the matched instance of IMarkupFilter, though the parameter is not an instance of IMarkupFilter, but a Class<? extends IMarkupFilter>.

We must iterate all registered IMarkupFilters and check if the Class of the IMarkupFilter matches with the parameter Class object for finding the index of 'beforeFilter'.


** HOW TO REPRODUCE

Unpack, build and run the attached project 'wicket-bug.tar.gz'. 
jp.javelindev.wicket.MyMarkupFactory will log all registered filters with source below:

<pre>
    @Override
    public MarkupParser newMarkupParser(MarkupResourceStream resource) {
        MarkupParser parser = super.newMarkupParser(resource);
        parser.add(new MyMarkupFilter(), WicketTagIdentifier.class);
        parser.add(new MyMarkupFilter2());

        for (IMarkupFilter filter : parser.getMarkupFilters()) {
            LOGGER.info("filter class: {}", filter.getClass());
        }

        return parser;
    }
</pre>

If MarkupParser add filters at correct place, 

- MyMarkupFilter must be displayed at first (because WicketTagIdentifier is the first filter in default implementation) and 
- MyMarkupFilter2 must be displayed before RelativePathPrefixHandler (because the default implementation of add() of MarkupFilterList is like 'add(filter, RelativePathPrefixHandler.class)').

But with trunk and wicket-1.5.4, both filters is displayed at last.

** WORK AROUND **

I can avoid this issue by getting raw MarkupFilterList through getMarkupFilters() and writing code manually to find correct place for add().

** PATCH **

I attached a patch to fix this issue. see the source of MarkupParser.


  was:
The documentation comment of MarkupParser#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) says that 'filter' will be added before the 'beforeFilter', but the filter passed is always added as the last element of MarkupFilterList.

Technically, MarkupParser#add() internally uses an inner-class MarkupFilterList for managing filters. But the MarkupFilterList#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) does not implemented correctly.

The method uses 'indexOf' of ArrayList for finding the matched instance of IMarkupFilter, though the parameter is not an instance of IMarkupFilter, but <? extends IMarkupFilter> beforeFilter).

We must iterate all registered IMarkupFilters and check if the Class of the IMarkupFilter matches with the parameter Class object for finding the index of 'beforeFilter'.


** HOW TO REPRODUCE

Unpack, build and run the attached project 'wicket-bug.tar.gz'. 
jp.javelindev.wicket.MyMarkupFactory will log all registered filters with source below:

<pre>
    @Override
    public MarkupParser newMarkupParser(MarkupResourceStream resource) {
        MarkupParser parser = super.newMarkupParser(resource);
        parser.add(new MyMarkupFilter(), WicketTagIdentifier.class);
        parser.add(new MyMarkupFilter2());

        for (IMarkupFilter filter : parser.getMarkupFilters()) {
            LOGGER.info("filter class: {}", filter.getClass());
        }

        return parser;
    }
</pre>

If MarkupParser add filters at correct place, 

- MyMarkupFilter must be displayed at first (because WicketTagIdentifier is the first filter in default implementation) and 
- MyMarkupFilter2 must be displayed before RelativePathPrefixHandler (because the default implementation of add() of MarkupFilterList is like 'add(filter, RelativePathPrefixHandler.class)').

But with trunk and wicket-1.5.4, both filters is displayed at last.

** WORK AROUND **

I can avoid this issue by getting raw MarkupFilterList through getMarkupFilters() and writing code manually to find correct place for add().

** PATCH **

I attached a patch to fix this issue. see the source of MarkupParser.


    
> MarkupParser#add(IMarkupFilter filter,Class beforeFilter) doesn't add the filter into the correct place.
> --------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-4390
>                 URL: https://issues.apache.org/jira/browse/WICKET-4390
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.4, 6.0.0
>         Environment: any platform
>            Reporter: Tsutomu YANO
>            Priority: Minor
>         Attachments: fix-WICKET-4390.patch, wicket-bug.tar.gz
>
>
> The documentation comment of MarkupParser#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) says that 'filter' will be added before the 'beforeFilter', but the filter passed is always added as the last element of MarkupFilterList.
> Technically, MarkupParser#add() internally uses an inner-class MarkupFilterList for managing filters. But the MarkupFilterList#add(IMarkupFilter filter,Class<? extends IMarkupFilter> beforeFilter) does not implemented correctly.
> The method uses 'indexOf' of ArrayList for finding the matched instance of IMarkupFilter, though the parameter is not an instance of IMarkupFilter, but a Class<? extends IMarkupFilter>.
> We must iterate all registered IMarkupFilters and check if the Class of the IMarkupFilter matches with the parameter Class object for finding the index of 'beforeFilter'.
> ** HOW TO REPRODUCE
> Unpack, build and run the attached project 'wicket-bug.tar.gz'. 
> jp.javelindev.wicket.MyMarkupFactory will log all registered filters with source below:
> <pre>
>     @Override
>     public MarkupParser newMarkupParser(MarkupResourceStream resource) {
>         MarkupParser parser = super.newMarkupParser(resource);
>         parser.add(new MyMarkupFilter(), WicketTagIdentifier.class);
>         parser.add(new MyMarkupFilter2());
>         for (IMarkupFilter filter : parser.getMarkupFilters()) {
>             LOGGER.info("filter class: {}", filter.getClass());
>         }
>         return parser;
>     }
> </pre>
> If MarkupParser add filters at correct place, 
> - MyMarkupFilter must be displayed at first (because WicketTagIdentifier is the first filter in default implementation) and 
> - MyMarkupFilter2 must be displayed before RelativePathPrefixHandler (because the default implementation of add() of MarkupFilterList is like 'add(filter, RelativePathPrefixHandler.class)').
> But with trunk and wicket-1.5.4, both filters is displayed at last.
> ** WORK AROUND **
> I can avoid this issue by getting raw MarkupFilterList through getMarkupFilters() and writing code manually to find correct place for add().
> ** PATCH **
> I attached a patch to fix this issue. see the source of MarkupParser.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira