Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-5073

UrlRenderer#removeCommonPrefixes() fails when contextPath+filterPrefix has more segments than the argument

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 6.6.0
    • 6.7.0, 1.5.11
    • wicket
    • None

    Description

      I get this exception when trying to create a URL with RequestCycle#urlFor:

      org.apache.wicket.WicketRuntimeException: An error occurred while generating an Url for handler 'ResourceReferenceRequestHandler

      {resourceReference=scope: org.apache.wicket.Application; name: ImageResource; locale: null; style: null; variation: null, pageParameters=publicId=[f74df62d-cbdb-49db-96e4-36e3ea62610e], type=[sr]}

      '
      at org.apache.wicket.request.cycle.RequestCycle.urlFor(RequestCycle.java:516) [wicket-core-6.6.0.jar:6.6.0]
      at org.apache.wicket.request.cycle.RequestCycle.urlFor(RequestCycle.java:473) [wicket-core-6.6.0.jar:6.6.0]
      at xxx.XXXWebApplication.urlFor(XXXWebApplication.java:161) ~[xxx-web-0.1.0-SNAPSHOT.jar:0.1.0-SNAPSHOT]
      [...]
      Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
      at java.util.ArrayList.rangeCheck(ArrayList.java:604) ~[na:1.7.0_10]
      at java.util.ArrayList.remove(ArrayList.java:445) ~[na:1.7.0_10]
      at org.apache.wicket.request.UrlRenderer.removeCommonPrefixes(UrlRenderer.java:319) ~[wicket-request-6.6.0.jar:6.6.0]
      at org.apache.wicket.request.UrlRenderer.renderRelativeUrl(UrlRenderer.java:220) ~[wicket-request-6.6.0.jar:6.6.0]
      at org.apache.wicket.request.UrlRenderer.renderUrl(UrlRenderer.java:117) ~[wicket-request-6.6.0.jar:6.6.0]
      at org.apache.wicket.request.cycle.RequestCycle.renderUrl(RequestCycle.java:529) [wicket-core-6.6.0.jar:6.6.0]
      at org.apache.wicket.request.cycle.RequestCycle.urlFor(RequestCycle.java:511) [wicket-core-6.6.0.jar:6.6.0]
      ... 46 common frames omitted

      The app uses a context path and no filter path. I see that UrlRenderer#removeCommonPrefixes receives an empty list and the code in the method assumes that context path + filter path is always a common prefix and tries to remove it later from the empty list.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            mgrigorov Martin Tzvetanov Grigorov
            cleiter Christoph Leiter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment