Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-2111

rewrite() handler doesn't guard against missing leading slash


      When using the rewrite() predicate language handler, if you have something like this:

      path( "foo" ) -> rewrite( "bar" )

      it will throw this exception:

      java.lang.IllegalArgumentException: UT000068: Servlet path match failed 

      I'm also seeing this error as well in my tests, though I think it's likely unrelated:

      java.lang.RuntimeException: null
              at io.undertow.server.HttpServerExchange.setStatusCode(HttpServerExchange.java:1484)
              at io.undertow.server.Connectors.executeRootHandler(Connectors.java:420)
              at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:256)
              at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136)
              at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:59)
              at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
              at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
              at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
              at org.xnio.nio.WorkerThread.run(WorkerThread.java:591) 

      Unless I'm mistaken, I'm thinking "foo" is an invalid relative URL since it needs to begin with a leading slash.  i.e. 

      rewrite( "/bar" ) 

      which works.   If it truly is invalid to set a relative URI with no leading slash and given the fact that predicates such as path() make the leading slash optional, I would recommend that the rewrite handler automatically add in any missing leading slashes to make it a bit more user friendly and prevent predicate rules from setting back URIs. 


            rhn-cservice-bbaranow Bartosz Baranowski
            bdw429s Brad Wood
            0 Vote for this issue
            2 Start watching this issue