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 00:31:01 UTC

groovy git commit: Avoid using the equals and hashCode methods of URL

Repository: groovy
Updated Branches:
  refs/heads/master 12997ac1d -> 6781fc5d0


Avoid using the equals and hashCode methods of URL

Because the equals and hashCode methods of URL are blocking


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

Branch: refs/heads/master
Commit: 6781fc5d0e75854e182afb15d6f0f1ea1b8c1ece
Parents: 12997ac
Author: sunlan <su...@apache.org>
Authored: Tue Dec 26 08:30:53 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Tue Dec 26 08:30:53 2017 +0800

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


http://git-wip-us.apache.org/repos/asf/groovy/blob/6781fc5d/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);
                                 }