You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2017/12/26 01:17:14 UTC

[3/3] groovy git commit: Avoid using the equals and hashCode methods of URL

Avoid using the equals and hashCode methods of URL

Because the equals and hashCode methods of URL are blocking

(cherry picked from commit 6781fc5)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/0e507c9d
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/0e507c9d
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/0e507c9d

Branch: refs/heads/GROOVY_2_6_X
Commit: 0e507c9d3f3d40bd58204c19c08c2c383aba5963
Parents: e6bccaf
Author: sunlan <su...@apache.org>
Authored: Tue Dec 26 08:30:53 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Tue Dec 26 09:17:06 2017 +0800

----------------------------------------------------------------------
 .../transform/ASTTransformationVisitor.java     | 24 +++++++++++++-------
 1 file changed, 16 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/0e507c9d/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java b/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java
index 2fbf6cd..77bc3cc 100644
--- a/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java
@@ -38,6 +38,7 @@ import org.codehaus.groovy.control.messages.WarningMessage;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -230,23 +231,30 @@ public final class ASTTransformationVisitor extends ClassCodeVisitorSupport {
                         continue;
                     }
                     Set<String> disabledGlobalTransforms = compilationUnit.getConfiguration().getDisabledGlobalASTTransformations();
-                    if (disabledGlobalTransforms==null) disabledGlobalTransforms=Collections.emptySet();
+                    if (disabledGlobalTransforms == null) disabledGlobalTransforms = Collections.emptySet();
                     while (className != null) {
                         if (!className.startsWith("#") && className.length() > 0) {
                             if (!disabledGlobalTransforms.contains(className)) {
                                 if (transformNames.containsKey(className)) {
-                                    if (!service.equals(transformNames.get(className))) {
+                                    try {
+                                        if (!service.toURI().equals(transformNames.get(className).toURI())) {
+                                            compilationUnit.getErrorCollector().addWarning(
+                                                    WarningMessage.POSSIBLE_ERRORS,
+                                                    "The global transform for class " + className + " is defined in both "
+                                                            + transformNames.get(className).toExternalForm()
+                                                            + " and "
+                                                            + service.toExternalForm()
+                                                            + " - the former definition will be used and the latter ignored.",
+                                                    null,
+                                                    null);
+                                        }
+                                    } catch (URISyntaxException e) {
                                         compilationUnit.getErrorCollector().addWarning(
                                                 WarningMessage.POSSIBLE_ERRORS,
-                                                "The global transform for class " + className + " is defined in both "
-                                                        + transformNames.get(className).toExternalForm()
-                                                        + " and "
-                                                        + service.toExternalForm()
-                                                        + " - the former definition will be used and the latter ignored.",
+                                                "Failed to parse URL as URI because of exception " + e.toString(),
                                                 null,
                                                 null);
                                     }
-
                                 } else {
                                     transformNames.put(className, service);
                                 }