You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2022/07/23 16:26:00 UTC

[jira] [Updated] (GROOVY-10519) v9 ClassFinder closes existing FileSystems that it doesn't own

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

Eric Milles updated GROOVY-10519:
---------------------------------
    Fix Version/s:     (was: 5.0.0-alpha-1)

> v9 ClassFinder closes existing FileSystems that it doesn't own
> --------------------------------------------------------------
>
>                 Key: GROOVY-10519
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10519
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 3.0.10, 4.0.0
>            Reporter: John Engelman
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 4.0.1, 3.0.11
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> {noformat}
> 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)) {
>     //...
>   }
>   //...
> }{noformat}
> 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.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)