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

v9 ClassFinder closes existing FileSystems that it doesn't own

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.10, 4.0.0
    • 4.0.1, 3.0.11
    • groovy-runtime
    • None

    Description

      org.codehaus.groovy.vmplugin.v9.ClassFinder
      
      private static FileSystem newFileSystem(URI uri) throws IOException {          
        try {            
          return FileSystems.newFileSystem(uri, Collections.emptyMap());        
        } catch (FileSystemAlreadyExistsException e) {            
          return FileSystems.getFileSystem(uri);        
        }    
      }
      
      private static Map<String, Set<String>> find(URI uri, String prefix, String packageName, boolean recursive) {        
        boolean wfs = "file".equals(uri.getScheme());        
        if (wfs) prefix = prefix.replace("/", File.separator);
        
        final String sepPatten = Pattern.quote(wfs ? File.separator : "/");          
        final int prefixElemCnt = prefix.trim().isEmpty() ? 0 : prefix.split(sepPatten).length;
        
        Map<String, Set<String>> result = new LinkedHashMap<>();        
        try (FileSystem fs = newFileSystem(uri)) {
          //...
        }
        //...
      }

      The current implementation of ClassFinder will close a FileSystem that was opened prior to loading Groovy classes. Specifically, if an application opens a FileSystem for a JAR on the classpath that contains Groovy classes and then subsequently loads a Groovy class contained within, then the underlying ZipFileSystem is closed by ClassFinder and the original application receives a java.nio.file.ClosedFileSystemException on subsequent operations.

      Attachments

        Activity

          People

            paulk Paul King
            johnrengelman John Engelman
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h