[ https://issues.apache.org/jira/browse/WICKET-4387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13397640#comment-13397640 ]
Darryl L. Miles commented on WICKET-4387: ----------------------------------------- I can confirm that with the inputs: String contextPath="/myapp" String filterPrefix="/foobar/" String uri="/myapp/foobar/abc" The output URL becomes "bc" with Wicket 1.5.7 where the leading "a" was chopped off. However in removing the "+ 1" addition a large number of unit tests start failing. So I can only describe the matter as some kind of "voodoo" in that it is doing a non-obvious thing and at the point of the non-obvious action it is not documented in the source with comments. Enclosed a file of the first unit test to fail wicket-core/target/surefire-reports/TEST-org.apache.wicket.markup.html.border.ComponentBorderTest.xml > StringIndexOutOfBoundsException when forwarding requests > -------------------------------------------------------- > > Key: WICKET-4387 > URL: https://issues.apache.org/jira/browse/WICKET-4387 > Project: Wicket > Issue Type: Bug > Components: wicket > Affects Versions: 1.5.4 > Reporter: Yossi Shaul > Assignee: Martin Grigorov > Priority: Critical > Fix For: 1.5.5, 6.0.0-beta1, 1.5.7 > > Attachments: > TEST-org.apache.wicket.markup.html.border.ComponentBorderTest.xml, > wicket.zip, wicket4387.zip > > > 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: > {code} > 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) > {code} > {code:title=web.xml snippet} > <filter> > <filter-name>forward</filter-name> > <filter-class>org.jfrog.ForwardFilter</filter-class> > </filter> > <filter> > <filter-name>wicket.wicket</filter-name> > > <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class> > <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> > {code} > This bug is opened here following a [bug we > found|https://issues.jfrog.org/jira/browse/RTFACT-4767] in Artifactory after > upgrading to Wicket 1.5 -- 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