[ 
https://issues.apache.org/jira/browse/TOBAGO-2050?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Udo Schnurpfeil resolved TOBAGO-2050.
-------------------------------------
    Resolution: Fixed

> StringIndexOutOfBoundsException in ...util.WebXmlUtils.normalizePath()
> ----------------------------------------------------------------------
>
>                 Key: TOBAGO-2050
>                 URL: https://issues.apache.org/jira/browse/TOBAGO-2050
>             Project: MyFaces Tobago
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 4.5.0
>            Reporter: Andy Price
>            Assignee: Udo Schnurpfeil
>            Priority: Major
>             Fix For: 4.5.4
>
>
> I have a servlet "/ExceptionHandler" listed as an error handler in my web.xml:
> {code:xml}
>         <error-page>
>                 
> <exception-type>javax.servlet.ServletException</exception-type>
>                 <location>/ExceptionHandler</location>
>         </error-page>
> {code}
> and it is triggering this bug in Tobago while attempting to handle an 
> exception in an ajax path:
> {noformat}
> 19:53:34,734 ERROR [io.undertow.request] (default task-19) UT005023: 
> Exception handling request to /incubation.xhtml: 
> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
>       at java.lang.String.substring(String.java:1967)
>       at 
> org.apache.myfaces.tobago.util.WebXmlUtils.normalizePath(WebXmlUtils.java:184)
>       at org.apache.myfaces.tobago.util.WebXmlUtils.init(WebXmlUtils.java:104)
>       at 
> org.apache.myfaces.tobago.util.WebXmlUtils.getErrorPageLocation(WebXmlUtils.java:50)
>       at 
> org.apache.myfaces.tobago.webapp.AjaxExceptionHandler.handle(AjaxExceptionHandler.java:68)
>       at 
> org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:216)
>       at 
> org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:142)
>       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:204)
>         ...
> {noformat}
> Looking at the relevant code in Tobago 
> ([https://github.com/apache/myfaces-tobago/blob/master/tobago-core/src/main/java/org/apache/myfaces/tobago/util/WebXmlUtils.java#L184]
>  ):
> {code:java}
>       if (path.endsWith(suffix)) {
>         return path;
>       } else {
>         return path.substring(0, path.lastIndexOf('.')) + suffix;
>       }
> {code}
> It appears to be assuming that the <location> entry is a path that has a '.' 
> separated suffix and when the path is "/ExceptionHandler" it throws the above 
> exception. (I don't understand why it's trying to 'normalize' the location by 
> replacing the suffix here; perhaps it isn't even needed.)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to