You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2019/10/23 23:10:32 UTC

[maven-resolver] branch MRESOLVER-93 created (now a28fb68)

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

tibordigana pushed a change to branch MRESOLVER-93
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git.


      at a28fb68  MRESOLVER-93 Fixed the test case Fixed the test case so that previous implementation throws StackoverflowError

This branch includes the following new commits:

     new 31b24df  Test case for MRESOLVER-93
     new 60bc482  Fixed MRESOLVER-93
     new a28fb68  MRESOLVER-93 Fixed the test case Fixed the test case so that previous implementation throws StackoverflowError

The 3 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.



[maven-resolver] 01/03: Test case for MRESOLVER-93

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch MRESOLVER-93
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git

commit 31b24dfe240997861e27661a7540546fbe6e0dab
Author: Tomo Suzuki <su...@google.com>
AuthorDate: Tue Aug 20 08:33:29 2019 -0400

    Test case for MRESOLVER-93
---
 .../graph/visitor/PathRecordingDependencyVisitorTest.java  | 14 ++++++++++++++
 .../test/resources/visitor/path-recorder/cycle-3paths.txt  |  7 +++++++
 2 files changed, 21 insertions(+)

diff --git a/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitorTest.java b/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitorTest.java
index cd766a0..5855726 100644
--- a/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitorTest.java
+++ b/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitorTest.java
@@ -135,6 +135,20 @@ public class PathRecordingDependencyVisitorTest
         assertPath( paths.get( 3 ), "a", "x", "x" );
     }
 
+    @Test
+    public void testGetPaths_HandlesCycles_threePaths()
+        throws Exception
+    {
+        DependencyNode root = parse( "cycle-3paths.txt" );
+
+        PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor( new ArtifactMatcher(), false );
+        root.accept( visitor );
+
+        List<List<DependencyNode>> paths = visitor.getPaths();
+        assertEquals( paths.toString(), 4, paths.size() );
+        assertPath( paths.get( 0 ), "a", "b", "c");
+    }
+
     private static class ArtifactMatcher
         implements DependencyFilter
     {
diff --git a/maven-resolver-util/src/test/resources/visitor/path-recorder/cycle-3paths.txt b/maven-resolver-util/src/test/resources/visitor/path-recorder/cycle-3paths.txt
new file mode 100644
index 0000000..d7308c8
--- /dev/null
+++ b/maven-resolver-util/src/test/resources/visitor/path-recorder/cycle-3paths.txt
@@ -0,0 +1,7 @@
+gid:a:1 (1)
++- gid:b:0
+|  \- ^1
++- gid:b:1
+|  \- ^1
+\- gid:b:2
+   \- ^1


[maven-resolver] 02/03: Fixed MRESOLVER-93

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch MRESOLVER-93
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git

commit 60bc4829b4753b7648a7554b41ca1d95ee88b4d0
Author: Tomo Suzuki <su...@google.com>
AuthorDate: Tue Aug 20 11:05:56 2019 -0400

    Fixed MRESOLVER-93
---
 .../util/graph/visitor/PathRecordingDependencyVisitor.java | 14 ++------------
 .../graph/visitor/PathRecordingDependencyVisitorTest.java  |  6 +++---
 .../test/resources/visitor/path-recorder/cycle-3paths.txt  |  2 +-
 3 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitor.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitor.java
index 463668c..3f1c8e2 100644
--- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitor.java
+++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitor.java
@@ -21,9 +21,7 @@ package org.eclipse.aether.util.graph.visitor;
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.IdentityHashMap;
 import java.util.List;
-import java.util.Map;
 
 import org.eclipse.aether.graph.DependencyFilter;
 import org.eclipse.aether.graph.DependencyNode;
@@ -42,8 +40,6 @@ public final class PathRecordingDependencyVisitor
 
     private final Stack<DependencyNode> parents;
 
-    private final Map<DependencyNode, Object> visited;
-
     private final boolean excludeChildrenOfMatches;
 
     /**
@@ -72,7 +68,6 @@ public final class PathRecordingDependencyVisitor
         this.excludeChildrenOfMatches = excludeChildrenOfMatches;
         paths = new ArrayList<>();
         parents = new Stack<>();
-        visited = new IdentityHashMap<>( 128 );
     }
 
     /**
@@ -101,6 +96,7 @@ public final class PathRecordingDependencyVisitor
     {
         boolean accept = filter == null || filter.accept( node, parents );
 
+        boolean hasDuplicateNodeInParent = parents.contains( node );
         parents.push( node );
 
         if ( accept )
@@ -118,18 +114,12 @@ public final class PathRecordingDependencyVisitor
             }
         }
 
-        if ( visited.put( node, Boolean.TRUE ) != null )
-        {
-            return false;
-        }
-
-        return true;
+        return !hasDuplicateNodeInParent;
     }
 
     public boolean visitLeave( DependencyNode node )
     {
         parents.pop();
-        visited.remove( node );
 
         return true;
     }
diff --git a/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitorTest.java b/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitorTest.java
index 5855726..a759d88 100644
--- a/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitorTest.java
+++ b/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitorTest.java
@@ -141,12 +141,12 @@ public class PathRecordingDependencyVisitorTest
     {
         DependencyNode root = parse( "cycle-3paths.txt" );
 
-        PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor( new ArtifactMatcher(), false );
+        PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor( new ArtifactMatcher() );
         root.accept( visitor );
 
         List<List<DependencyNode>> paths = visitor.getPaths();
-        assertEquals( paths.toString(), 4, paths.size() );
-        assertPath( paths.get( 0 ), "a", "b", "c");
+        assertEquals( paths.toString(), 1, paths.size() );
+        assertPath( paths.get( 0 ), "a", "b");
     }
 
     private static class ArtifactMatcher
diff --git a/maven-resolver-util/src/test/resources/visitor/path-recorder/cycle-3paths.txt b/maven-resolver-util/src/test/resources/visitor/path-recorder/cycle-3paths.txt
index d7308c8..37e675d 100644
--- a/maven-resolver-util/src/test/resources/visitor/path-recorder/cycle-3paths.txt
+++ b/maven-resolver-util/src/test/resources/visitor/path-recorder/cycle-3paths.txt
@@ -3,5 +3,5 @@ gid:a:1 (1)
 |  \- ^1
 +- gid:b:1
 |  \- ^1
-\- gid:b:2
+\- match:b:2
    \- ^1


[maven-resolver] 03/03: MRESOLVER-93 Fixed the test case Fixed the test case so that previous implementation throws StackoverflowError

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch MRESOLVER-93
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git

commit a28fb689e4d0a36c27f3a640a856ea4804fd8c72
Author: Tomo Suzuki <su...@google.com>
AuthorDate: Wed Aug 21 11:55:28 2019 -0400

    MRESOLVER-93 Fixed the test case
    Fixed the test case so that previous implementation throws StackoverflowError
---
 .../src/test/resources/visitor/path-recorder/cycle-3paths.txt        | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/maven-resolver-util/src/test/resources/visitor/path-recorder/cycle-3paths.txt b/maven-resolver-util/src/test/resources/visitor/path-recorder/cycle-3paths.txt
index 37e675d..11dd250 100644
--- a/maven-resolver-util/src/test/resources/visitor/path-recorder/cycle-3paths.txt
+++ b/maven-resolver-util/src/test/resources/visitor/path-recorder/cycle-3paths.txt
@@ -3,5 +3,6 @@ gid:a:1 (1)
 |  \- ^1
 +- gid:b:1
 |  \- ^1
-\- match:b:2
-   \- ^1
++- gid:b:2
+|  \- ^1
+\- match:b:3