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

StringIndexOutOfBoundsException when forwarding requests

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

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 1.5.4
    • 1.5.5, 1.5.7, 6.0.0-beta1
    • wicket
    • None

    Description

      We're getting StringIndexOutOfBoundsException from wicket when forwarding a request from our servlet filter (using request dispatcher) to wicket.
      The problem occurs whenever the original URI is shorter than the wicket filter mapping.
      I created an example webapp (based on the quickstart) in which a ForwardFilter is mapped to /f/* and it forwards all the requests to /wicket/ (see web.xml snippet below).
      With this webapp a request to "http://localhost:8081/wicket/f/" results in the following exception:

      ERROR - RequestCycle               - Error during processing error message
      java.lang.StringIndexOutOfBoundsException: String index out of range: -5
              at java.lang.String.substring(String.java:1958)
              at java.lang.String.substring(String.java:1925)
              at org.apache.wicket.protocol.http.servlet.ServletWebRequest.getContextRelativeUrl(ServletWebRequest.java:180)
              at org.apache.wicket.protocol.http.servlet.ServletWebRequest.getClientUrl(ServletWebRequest.java:140)
              at org.apache.wicket.request.UrlRenderer.<init>(UrlRenderer.java:59)
              at org.apache.wicket.request.cycle.RequestCycle.newUrlRenderer(RequestCycle.java:148)
              at org.apache.wicket.request.cycle.RequestCycle.getUrlRenderer(RequestCycle.java:172)
              at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:145)
              at org.apache.wicket.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:167)
              at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:781)
              at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
              at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:304)
              at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)
              at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)
              at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)
              at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)
              at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)
              at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)
              at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)
              at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)
              at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)
              at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)
              at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:227)
              at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:283)
              at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:162)
              at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:218)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
              at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
              at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
              at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
              at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
              at org.jfrog.ForwardFilter.doFilter(ForwardFilter.java:22)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
              at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
              at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:284)
              at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:322)
              at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1714)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
              at java.lang.Thread.run(Thread.java:722)
      
      web.xml snippet
      	<filter>
      		<filter-name>forward</filter-name>
      		<filter-class&gt;org.jfrog.ForwardFilter</filter-class&gt;
      	</filter>
      
      	<filter>
      		<filter-name>wicket.wicket</filter-name>
      		<filter-class&gt;org.apache.wicket.protocol.http.WicketFilter</filter-class&gt;
      		<init-param>
      			<param-name>applicationClassName</param-name>
      			<param-value>org.jfrog.WicketApplication</param-value>
      		</init-param>
      	</filter>
      
      	<filter-mapping>
      		<filter-name>forward</filter-name>
      		<url-pattern>/f/*</url-pattern>
      	</filter-mapping>
      
      	<filter-mapping>
      		<filter-name>wicket.wicket</filter-name>
      		<url-pattern>/wicket/*</url-pattern>
              <dispatcher>FORWARD</dispatcher>
              <dispatcher>REQUEST</dispatcher>
      	</filter-mapping>
      

      This bug is opened here following a bug we found in Artifactory after upgrading to Wicket 1.5

      Attachments

        Issue Links

        Activity

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

          People

            mgrigorov Martin Tzvetanov Grigorov
            yossis Yossi Shaul
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment