Uploaded image for project: 'Alfresco'
  1. Alfresco
  2. ALF-14000

getClassLoader().getResource(scriptClasspath) not guaranteed to work with absolute paths

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Unprioritized
    • Resolution: Not a bug
    • Affects Version/s: 4.0.d Community
    • Fix Version/s: None
    • Component/s: JavaScript API
    • Security Level: external (External user)
    • Labels:
      None

      Description

      getResource(scriptClasspath) does not guarantee to work when absolute paths are used.

      One occurance is at JSScriptProcessor:222

      InputStream stream = getClass().getClassLoader().getResource(scriptClasspath).openStream();

      This fails throwing a NPE when the GrailsRootLoader is used. This case might not be relevant, but I guess this can also fail in other environments - like maven builds or so.

      Further explanation is at http://www.thinkplexx.com/learn/howto/java/system/java-resource-loading-explained-absolute-and-relative-names-difference-between-classloader-and-class-resource-loading

      The attached patch fixed this for me and - as far as I can tell did not introduce other problems. I have only checked where "classpath:/" is used in Javascript sources, so there may still be other code trying to resolve resources in a similiar fashion.

        Attachments

          Structure

            Activity

              People

              • Assignee:
                closedissues Closed Issues
                Reporter:
                deas0815 Andreas Steffan (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Date of First Response:

                  Structure Helper Panel