You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by fschrogl <gi...@git.apache.org> on 2017/08/26 20:21:00 UTC

[GitHub] wicket pull request #230: Replace filterPath pattern '/*' with empty string

GitHub user fschrogl opened a pull request:

    https://github.com/apache/wicket/pull/230

    Replace filterPath pattern '/*' with empty string

    A filterPath pattern of '/*' is now replaced with an empty string. This matches the behavior of methods getFilterPathFromAnnotation() and getFilterPathFromConfig().
    
    I'm not sure if it's a bug, but I noticed the different beahvior when initializing Wicket in a Spring Boot application. When using a @WebFilter("/*") annotation or the init parameter filterMappingUrlPattern="/*" Wicket works as expected, but when doing the same programmatically with wicketFilter.setFilterPath("/*") the path gets internally rewritten to "*/" and Wicket than only handles HTTP requests to the root path.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/fschrogl/wicket patch-1

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/wicket/pull/230.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #230
    
----
commit 6ed034ec23213d50b799e6b6eb2b721eb7a3a9ce
Author: Fritz Schrogl <fs...@users.noreply.github.com>
Date:   2017-08-26T20:20:19Z

    Replace filterPath pattern '/*' with empty string
    
    A filterPath pattern of '/*' is now replaced with an empty string. This matches the behavior of methods getFilterPathFromAnnotation() and getFilterPathFromConfig().

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] wicket issue #230: Replace filterPath pattern '/*' with empty string

Posted by klopfdreh <gi...@git.apache.org>.
Github user klopfdreh commented on the issue:

    https://github.com/apache/wicket/pull/230
  
    Just my thoughts:
    
    /* - maps every path - root paths and sub paths to the specific filter
    / - maps only the root path but not every sub path
    
    So from my understanding they aren't the same and shouldn't be mixed up.
    
    https://stackoverflow.com/questions/4140448/difference-between-and-in-servlet-mapping-url-pattern
    
    Maybe we should inspect this a bit more to achieve the right handling.
    
    WDTY?


---

[GitHub] wicket issue #230: Replace filterPath pattern '/*' with empty string

Posted by klopfdreh <gi...@git.apache.org>.
Github user klopfdreh commented on the issue:

    https://github.com/apache/wicket/pull/230
  
    @martin-g what do you thing of extracting the lines:
    
    https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java#L583
    
    to 
    
    https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java#L599
    
    into a method and call this method within getFilterPath and getFilterPathFromConfig?


---

[GitHub] wicket issue #230: Replace filterPath pattern '/*' with empty string

Posted by martin-g <gi...@git.apache.org>.
Github user martin-g commented on the issue:

    https://github.com/apache/wicket/pull/230
  
    bq. wicketFilter.setFilterPath("/") the path gets internally rewritten to "/"
    
    Is something missing here ? The values are the same - `"/"`, so I do not understand what is rewritten.
    Can you please provide your Spring Boot configuration related to WicketFilter that breaks your app ? I also have Spring Boot based app and I can try it locally to verify the problem..
    Thanks!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] wicket issue #230: Replace filterPath pattern '/*' with empty string

Posted by fschrogl <gi...@git.apache.org>.
Github user fschrogl commented on the issue:

    https://github.com/apache/wicket/pull/230
  
    I tried to initialize Wicket using WicketFilter class and three different approaches (one after another). That's where I noticed the different behavior (at least that's how I understand it).
    
    __(1) Using setFilterPath method__
    
        @Bean
        public FilterRegistrationBean<WicketFilter> initWicketFilterByGetter() {
          WicketFilter wicketFilter = new WicketFilter(new MyWicketApplication());
          // filterPath '/' works for all paths
          // filterPath '/*' only works for root path
          wicketFilter.setFilterPath("/");
          return new FilterRegistrationBean<>(wicketFilter);
        }
    
    __(2) Using init params__
    
        @Bean
        public FilterRegistrationBean<WicketFilter> initWicketFilterByInitParam() {
          WicketFilter wicketFilter = new WicketFilter(new MyWicketApplication());
          FilterRegistrationBean<WicketFilter> wicketFilterRegistrationBean = new FilterRegistrationBean<>(wicketFilter);
          // Using '/*' works for all paths, using '/' leads to an exception
          wicketFilterRegistrationBean.addInitParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*");
          return wicketFilterRegistrationBean;
        }
    
    __(3) Using `@WebFilter` annotation on a custom filter and `@ServletComponentScan` for Spring Boot__
    
        // /* works, / doesn't work
        @WebFilter(value = "/*", initParams = @WebInitParam(name = "applicationClassName", value = "package.MyWicketApplication"))
        public static class MyWicketFilter extends WicketFilter {  }
    
    In approach __(1)__ I have to use `/` while in approaches __(2)__ and __(3)__ I have to use `/*` to achieve the same outcome.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---