Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7018

GroovyClassLoader addClasspath RegexPattern issue

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.6
    • 2.4.4
    • GroovyScriptEngine
    • None
    • JDK 1.7u51

    Description

      When adding Groovy Files from the file system to the GroovyClassLoader's classpath grabbed from a default java properties file ("/" instead of "\"))
      Then the addClasspath() method uses a simple URL instead of the File URL

      This is due to a simple mistake in this mentioned method:

      public void addClasspath(final String path) {
      ....
           if (!URI_PATTERN.matcher(path).matches()) {
                newURI = new File(path).toURI();
           } else {
                newURI = new URI(path);
           }
      }
      
      private static final Pattern URI_PATTERN = Pattern.compile("\\p{Alpha}[-+.\\p{Alnum}]*:[^\\\\]*");
      

      The URI_PATTERN which should match "URIs but not Windows filenames" doesn't work as expected.
      It matches i.e. C:/xxx/file.ext
      This is related to using forward instead of backslashes - which souldn't matter.

      This was i.e. NOT the case for Groovy 2.1.3

      Attachments

        Issue Links

          Activity

            People

              pascalschumacher Pascal Schumacher
              stefan_leo Stefan Leonhartsberger
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: