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

StringIndexOutOfBoundsException when a servlet matches both a prefix and extension

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.2.6.Final
    • 2.2.4.Final
    • Servlet
    • None

      Given a servlet registered to "/" and ".ext", requests which attempt to read getHttpServletMapping result in StringIndexOutOfBoundsException attempting to substring an empty string.
      The problem is the current implementation expects the matched portion to match the uri, however it doesn't contain the trailing component when an extension is matched.

      Caused by: java.lang.StringIndexOutOfBoundsException: begin 0, end -5, length 0
              at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319)
              at java.base/java.lang.String.substring(String.java:1874)
              at io.undertow.servlet.spec.HttpServletRequestImpl.getHttpServletMapping(HttpServletRequestImpl.java:258)
              at org.springframework.web.util.UrlPathHelper$Servlet4Delegate.skipServletPathDetermination(UrlPathHelper.java:780)
              at org.springframework.web.util.UrlPathHelper.skipServletPathDetermination(UrlPathHelper.java:272)
              at org.springframework.web.util.UrlPathHelper.getLookupPathForRequest(UrlPathHelper.java:251)
              at org.springframework.web.util.UrlPathHelper.resolveAndCacheLookupPath(UrlPathHelper.java:200)

              flaviarnn Flavia Rainone
              carterkozak Carter Kozak
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: