[groovy] branch GROOVY-9480 created (now 2670a92)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[groovy] branch GROOVY-9480 created (now 2670a92)

Daniel.Sun
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a change to branch GROOVY-9480
in repository https://gitbox.apache.org/repos/asf/groovy.git.


      at 2670a92  GROOVY-9480: New v9 ClassFinder throws NoSuchFileException/UnsupportedOperationException and writes it to stderr

This branch includes the following new commits:

     new 2670a92  GROOVY-9480: New v9 ClassFinder throws NoSuchFileException/UnsupportedOperationException and writes it to stderr

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Apache Groovy committer & PMC member

Blog: http://blog.sunlan.me
Twitter: @daniel_sun
Reply | Threaded
Open this post in threaded view
|

[groovy] 01/01: GROOVY-9480: New v9 ClassFinder throws NoSuchFileException/UnsupportedOperationException and writes it to stderr

Daniel.Sun
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY-9480
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 2670a92a82e970e9696995e156611333e3bbc27a
Author: Daniel Sun <[hidden email]>
AuthorDate: Thu Mar 26 08:36:56 2020 +0800

    GROOVY-9480: New v9 ClassFinder throws NoSuchFileException/UnsupportedOperationException and writes it to stderr
---
 src/main/java/org/codehaus/groovy/vmplugin/v9/ClassFinder.java  | 7 ++++++-
 src/test/org/codehaus/groovy/vmplugin/v9/ClassFinderTest.groovy | 9 +++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v9/ClassFinder.java b/src/main/java/org/codehaus/groovy/vmplugin/v9/ClassFinder.java
index 4bfe659..c7a7be8 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v9/ClassFinder.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v9/ClassFinder.java
@@ -18,6 +18,8 @@
  */
 package org.codehaus.groovy.vmplugin.v9;
 
+import groovy.lang.GroovyRuntimeException;
+
 import java.io.File;
 import java.io.IOException;
 import java.net.URI;
@@ -147,7 +149,10 @@ public class ClassFinder {
             });
         } catch (UnsupportedOperationException ignored) {
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new GroovyRuntimeException(
+                    String.format("Failed to find classes via uri: %s, prefix: %s, packageName: %s, recursive: %s",
+                            uri, prefix, packageName, recursive
+                    ), e);
         }
 
         return result;
diff --git a/src/test/org/codehaus/groovy/vmplugin/v9/ClassFinderTest.groovy b/src/test/org/codehaus/groovy/vmplugin/v9/ClassFinderTest.groovy
index 953bd1a..fc4838b 100644
--- a/src/test/org/codehaus/groovy/vmplugin/v9/ClassFinderTest.groovy
+++ b/src/test/org/codehaus/groovy/vmplugin/v9/ClassFinderTest.groovy
@@ -102,4 +102,13 @@ class ClassFinderTest {
 
         assert (ResolveVisitor.DEFAULT_IMPORTS as List).sort() == r1.values().stream().flatMap(e -> e.stream()).collect(Collectors.toSet()).sort()
     }
+
+    @Test
+    void testGroovy9480() {
+        try {
+            ClassFinder.find(URI.create("file:/NOT_FOUND"), "org/")
+        } catch (GroovyRuntimeException e) {
+            assert e.message.contains('Failed to find classes')
+        }
+    }
 }

Apache Groovy committer & PMC member

Blog: http://blog.sunlan.me
Twitter: @daniel_sun