[groovy] branch GROOVY-9480 updated (5c45d19 -> 3cfed44)

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

[groovy] branch GROOVY-9480 updated (5c45d19 -> 3cfed44)

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.


 discard 5c45d19  GROOVY-9480: New v9 ClassFinder throws NoSuchFileException/UnsupportedOperationException and writes it to stderr
     new 3cfed44  GROOVY-9480: New v9 ClassFinder throws NoSuchFileException/UnsupportedOperationException and writes it to stderr

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (5c45d19)
            \
             N -- N -- N   refs/heads/GROOVY-9480 (3cfed44)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

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.


Summary of changes:
 .../groovy/vmplugin/v9/ClassFindFailedException.java         | 12 ++++++------
 .../java/org/codehaus/groovy/vmplugin/v9/ClassFinder.java    |  4 +---
 .../org/codehaus/groovy/vmplugin/v9/ClassFinderTest.groovy   |  2 +-
 3 files changed, 8 insertions(+), 10 deletions(-)
 copy subprojects/groovy-json/src/test/groovy/groovy/json/JsonSlurperIndexOverlayTest.groovy => src/main/java/org/codehaus/groovy/vmplugin/v9/ClassFindFailedException.java (76%)

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 3cfed44dc6bcca34fb5495a5d7f32b01db40b7b9
Author: Daniel Sun <[hidden email]>
AuthorDate: Thu Mar 26 11:51:25 2020 +0800

    GROOVY-9480: New v9 ClassFinder throws NoSuchFileException/UnsupportedOperationException and writes it to stderr
---
 .../vmplugin/v9/ClassFindFailedException.java      | 29 ++++++++++++++++++++++
 .../codehaus/groovy/vmplugin/v9/ClassFinder.java   |  5 +++-
 .../groovy/vmplugin/v9/ClassFinderTest.groovy      |  9 +++++++
 3 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v9/ClassFindFailedException.java b/src/main/java/org/codehaus/groovy/vmplugin/v9/ClassFindFailedException.java
new file mode 100644
index 0000000..06067c7
--- /dev/null
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v9/ClassFindFailedException.java
@@ -0,0 +1,29 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.codehaus.groovy.vmplugin.v9;
+
+/**
+ *  Represents error occurred during finding classes
+ *  @since 3.0.3
+ */
+public class ClassFindFailedException extends RuntimeException {
+    public ClassFindFailedException(String msg, Throwable t) {
+        super(msg, t);
+    }
+}
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..12d7197 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v9/ClassFinder.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v9/ClassFinder.java
@@ -147,7 +147,10 @@ public class ClassFinder {
             });
         } catch (UnsupportedOperationException ignored) {
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new ClassFindFailedException(
+                    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..824d5ff 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_EXISTS", "org/", false)
+        } catch (ClassFindFailedException e) {
+            assert e.message.contains('Failed to find classes')
+        }
+    }
 }

Apache Groovy committer & PMC member

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