Wicket
  1. Wicket
  2. WICKET-4737

IllegalStateException on WicketFilter.init() after calling setFilterPath()

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.0.0
    • Fix Version/s: 6.1.0
    • Component/s: wicket
    • Labels:
      None
    • Environment:
      When you pre-configure the filter path using the setFilterPath() method.

      Description

      WICKET-4626 broke the ability to pre-set the filter path using setFilterPath(). The patch introduced by WICKET-4626 calls setFilterPath() from within WicketFilter.init(), and setFilterPath() throws IllegalStateException if it is called more than once.

        Issue Links

          Activity

          Jesse Long created issue -
          Hide
          Martin Grigorov added a comment -

          Can't you use org.apache.wicket.protocol.http.WicketFilter#FILTER_MAPPING_PARAM ?
          I.e. an <init-param><param-name>filterMappingUrlPattern</param-name><param-value>yours</param-value></init-param>

          Show
          Martin Grigorov added a comment - Can't you use org.apache.wicket.protocol.http.WicketFilter#FILTER_MAPPING_PARAM ? I.e. an <init-param><param-name>filterMappingUrlPattern</param-name><param-value>yours</param-value></init-param>
          Hide
          Jesse Long added a comment -

          Doesn't matter, why take away a nice feature when there is no need to? Right now, setFilterPath() is useless to anyone except WicketFilter.init(). Either it must work, or it should be removed.

          I'll use init params to work around in the mean time, but I like the feature and I'd like it to work again in 6.0.1.

          Show
          Jesse Long added a comment - Doesn't matter, why take away a nice feature when there is no need to? Right now, setFilterPath() is useless to anyone except WicketFilter.init(). Either it must work, or it should be removed. I'll use init params to work around in the mean time, but I like the feature and I'd like it to work again in 6.0.1.
          Hide
          Jesse Long added a comment -

          This is a patch to solve the problem...

          Show
          Jesse Long added a comment - This is a patch to solve the problem...
          Jesse Long made changes -
          Field Original Value New Value
          Attachment WICKET-4737.patch [ 12543065 ]
          Martin Grigorov made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Assignee Martin Grigorov [ mgrigorov ]
          Fix Version/s 6.0.1 [ 12322956 ]
          Resolution Fixed [ 1 ]
          Martin Grigorov made changes -
          Link This issue is duplicated by WICKET-4747 [ WICKET-4747 ]
          Hide
          Christoph Leiter added a comment -

          The easiest workaround (until 6.0.1 is released) seems to be to call getWicketFilter().setFilterPath(path) in WebApplication#init.

          Show
          Christoph Leiter added a comment - The easiest workaround (until 6.0.1 is released) seems to be to call getWicketFilter().setFilterPath(path) in WebApplication#init.
          Hide
          Jesse Long added a comment -

          No, WicketFilter.setFilterPath() cannot be called more than once in Wicket 1.5.x and Wicket 6. The problem was (now fixed, thanks Martin) that WicketFilter.init() would call WicketFilter.setFilterPath(), even if it was previously called, causing IllegalStateException.

          If we call WicketFilter.setFilterPath() from WebApplication.init() then our call will be the second call, and it would still throw an IllegalStateException.

          Show
          Jesse Long added a comment - No, WicketFilter.setFilterPath() cannot be called more than once in Wicket 1.5.x and Wicket 6. The problem was (now fixed, thanks Martin) that WicketFilter.init() would call WicketFilter.setFilterPath(), even if it was previously called, causing IllegalStateException. If we call WicketFilter.setFilterPath() from WebApplication.init() then our call will be the second call, and it would still throw an IllegalStateException.
          Hide
          Christoph Leiter added a comment -

          I understand the problem. The workaround works for me. See this code in WicketFilter:

          if (getFilterPath() == null)

          { log.warn("Unable to determine filter path from filter init-parm, web.xml, " + "or servlet 3.0 annotations. Assuming user will set filter path " + "manually by calling setFilterPath(String)"); }

          setFilterPath() is never called and we have the chance to invoke it in WebApplication#init.

          Show
          Christoph Leiter added a comment - I understand the problem. The workaround works for me. See this code in WicketFilter: if (getFilterPath() == null) { log.warn("Unable to determine filter path from filter init-parm, web.xml, " + "or servlet 3.0 annotations. Assuming user will set filter path " + "manually by calling setFilterPath(String)"); } setFilterPath() is never called and we have the chance to invoke it in WebApplication#init.
          Hide
          Jesse Long added a comment -

          Good point, yes, that will work.

          Show
          Jesse Long added a comment - Good point, yes, that will work.
          Emond Papegaaij made changes -
          Fix Version/s 6.1.0 [ 12322957 ]
          Fix Version/s 6.0.1 [ 12322956 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          8h 18m 1 Martin Grigorov 30/Aug/12 18:55

            People

            • Assignee:
              Martin Grigorov
              Reporter:
              Jesse Long
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development