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

PathHandler exception on index page access

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.3.0.Beta11, 1.2.12.Final
    • 1.3.0.Beta9
    • Core
    • None
    • Hide

      I set up an EAR with several modules. The EAR is deployed to "/lams" context path.

      The main module uses ServletExtension to catch authentication URLs and do some magic.

      deploymentInfo.addOuterHandlerChainWrapper(new HandlerWrapper() {
         public HttpHandler wrap(final HttpHandler handler) {
              return Handlers.path(handler).addExactPath("/j_security_check", new HttpHandler() {
                   //magic
              });
      }});
      

      So a PathHandler is in use.

      When I access an exact resource, like this
      http://localhost:8080/lams/index.jsp
      everything works fine.

      When I access just the context path
      http://localhost:8080/lams
      PathHandler throws

      Exception handling request to /lams/: java.lang.StringIndexOutOfBoundsException: String index out of range: -4
      

      The reason for that is PathHandler.handleRequest() method.
      It expects exchange.requestPath to be the full path.
      But in the method values are:
      exchange.requestPath = /lams/
      exchange.relativePath = /index.jsp

      When substring is attempted in line #89, it does not take into account that requestPath is not the full path, just the "browser path", and causes the exception.

      It seems either PathHandler (not expecting this situation) or HttpServerExchange (not filling the fields right) issue.

      I can not post the source code as it is pretty big.

      Show
      I set up an EAR with several modules. The EAR is deployed to "/lams" context path. The main module uses ServletExtension to catch authentication URLs and do some magic. deploymentInfo.addOuterHandlerChainWrapper( new HandlerWrapper() { public HttpHandler wrap( final HttpHandler handler) { return Handlers.path(handler).addExactPath( "/j_security_check" , new HttpHandler() { //magic }); }}); So a PathHandler is in use. When I access an exact resource, like this http://localhost:8080/lams/index.jsp everything works fine. When I access just the context path http://localhost:8080/lams PathHandler throws Exception handling request to /lams/: java.lang.StringIndexOutOfBoundsException: String index out of range: -4 The reason for that is PathHandler.handleRequest() method. It expects exchange.requestPath to be the full path. But in the method values are: exchange.requestPath = /lams/ exchange.relativePath = /index.jsp When substring is attempted in line #89, it does not take into account that requestPath is not the full path, just the "browser path", and causes the exception. It seems either PathHandler (not expecting this situation) or HttpServerExchange (not filling the fields right) issue. I can not post the source code as it is pretty big.

      When a PathHandler is in use and URL with context only (no exact resource) is fetched, a StringIndexOutOfBoundsException occurs.

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              trybik03 Marcin Cieślak (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: