[ 
https://issues.apache.org/jira/browse/GROOVY-9480?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17067260#comment-17067260
 ] 

Daniel Sun commented on GROOVY-9480:
------------------------------------

It's better to wrap and throw the exception and let its user decide how to deal 
with it.

https://github.com/apache/groovy/pull/1205

> New v9 ClassFinder throws NoSuchFileException/UnsupportedOperationException 
> and writes it to stderr
> ---------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-9480
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9480
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 3.0.2
>            Reporter: Eric Milles
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> {code:java}
> org.codehaus.groovy.vmplugin.v9.ClassFinder
>     private static Map<String, Set<String>> find(URI uri, String prefix, 
> String packageName, boolean recursive) {
>         ...
>         try (FileSystem fs = newFileSystem(uri)) {
>             ...
>         } catch (UnsupportedOperationException ignored) {
>         } catch (Exception e) {
>             e.printStackTrace(); // boo!
>         }
> {code}
> {code}
> java.nio.file.NoSuchFileException: C:\Users\...\org.codehaus.groovy30\groovy
>       at 
> java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
>       at 
> java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
>       at 
> java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
>       at 
> java.base/sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:53)
>       at 
> java.base/sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:38)
>       at 
> java.base/sun.nio.fs.WindowsFileSystemProvider.readAttributes(WindowsFileSystemProvider.java:198)
>       at java.base/java.nio.file.Files.readAttributes(Files.java:1763)
>       at 
> java.base/java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:219)
>       at java.base/java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
>       at java.base/java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
>       at java.base/java.nio.file.Files.walkFileTree(Files.java:2716)
>       at java.base/java.nio.file.Files.walkFileTree(Files.java:2796)
>       at 
> org.codehaus.groovy.vmplugin.v9.ClassFinder.find(ClassFinder.java:119)
>       at 
> org.codehaus.groovy.vmplugin.v9.ClassFinder.find(ClassFinder.java:107)
>       at org.codehaus.groovy.vmplugin.v9.Java9.doFindClasses(Java9.java:107)
>       at 
> org.codehaus.groovy.vmplugin.v9.Java9.getDefaultImportClasses(Java9.java:95)
>       at 
> org.codehaus.groovy.control.ResolveVisitor.<clinit>(ResolveVisitor.java:670)
>       at 
> org.codehaus.groovy.control.CompilationUnit.<init>(CompilationUnit.java:124)
>       at 
> org.codehaus.groovy.control.CompilationUnit.<init>(CompilationUnit.java:161)
>       at ...
>       Suppressed: java.lang.UnsupportedOperationException
>               at 
> java.base/sun.nio.fs.WindowsFileSystem.close(WindowsFileSystem.java:91)
>               at 
> org.codehaus.groovy.vmplugin.v9.ClassFinder.find(ClassFinder.java:118)
>               ... 18 more
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to