Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-4107

StringIndexOutOfBoundsException in getResourceVersion

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.0.24, 2.1.18, 2.2.12, 2.3.0
    • 2.3.0-beta
    • None
    • None
    • WebSphere Liberty

    Description

      I've run into a case where, given an incorrect context parameter, a StringIndexOutOfBoundsException is thrown. This occurs in WebSphere Liberty because the server normalizes the external context resource paths during app initialization.

      For example, this parameter:

      <context-param>
      <param-name>javax.faces.WEBAPP_RESOURCES_DIRECTORY</param-name>
      <param-value>/META-INF/resources</param-value>
      </context-param>

      throws:

      java.lang.StringIndexOutOfBoundsException: String index out of range: 35
      at java.lang.String.substring(String.java:1377)
      at org.apache.myfaces.shared.resource.ExternalContextResourceLoader.getResourceVersion(ExternalContextResourceLoader.java:81)

      That parameter value is not allowed to have a leading slash. However, the current exception is not very helpful, and can be easily avoided.

      I'll attach a patch which avoids the StringIndexOutOfBoundsException in getResourceVersion(); we already have this logic in getLibraryVersion().

      Attachments

        1. MYFACES-4107.patch
          2 kB
          Bill Lucy

        Activity

          People

            wtlucy Bill Lucy
            wtlucy Bill Lucy
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: