maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mickael Istria (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MNG-6563) StackOverflowError when reading deep (1000) project hierarchy
Date Mon, 14 Jan 2019 09:38:00 GMT

    [ https://issues.apache.org/jira/browse/MNG-6563?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16741886#comment-16741886
] 

Mickael Istria commented on MNG-6563:
-------------------------------------

Here is the code I use to generate the project
{code:java}
  private Set<File> buildLinearHierarchy(int depth, File tempDirectory) throws FileNotFoundException
{
    Set<File> poms = new HashSet<>(depth, 1.f);
    for(int i = 0; i < depth; i++ ) {
      File projectDir = new File(tempDirectory, "p" + i);
      projectDir.mkdirs();
      File pom = new File(projectDir, "pom.xml");
      poms.add(pom);
      try (PrintStream content = new PrintStream(pom);) {
        content.println("<project>");
        content.println("  <modelVersion>4.0.0</modelVersion>");
        content.println("  <groupId>org.eclipse.m2e.core.tests.hierarchy</groupId>");
        content.println("  <artifactId>pNUMBER</artifactId>".replace("NUMBER",
Integer.toString(i)));
        content.println("  <version>1</version>");
        content.println("  <packaging>pom</packaging>");
        if(i > 1) {
          content.println("  <parent>");
          content.println("    <groupId>org.eclipse.m2e.core.tests.hierarchy</groupId>");
          content.println("    <artifactId>pNUMBER</artifactId>".replace("NUMBER",
Integer.toString(i - 1)));
          content.println("    <version>1</version>");
          content.println("    <relativePath>../pNUMBER</relativePath>".replace("NUMBER",
Integer.toString(i - 1)));
          content.println("  </parent>");
        }
        content.println("</project>");
      }
    }
    return poms;
  }
{code}
then, invoking "DefaultProjectBuilder.build(new File("p999"))" should crash with a StackOverflowError.
I don't have the opportunity to automate such test right now.

One approach could be to reorganize the builder to first resolve the dependency chain as a
Queue of Files and then build them from parents to leaves, caching each result in the meantime
so it's processed only once.

> StackOverflowError when reading deep (1000) project hierarchy
> -------------------------------------------------------------
>
>                 Key: MNG-6563
>                 URL: https://issues.apache.org/jira/browse/MNG-6563
>             Project: Maven
>          Issue Type: Bug
>          Components: core
>            Reporter: Mickael Istria
>            Priority: Major
>
> I'm trying to write tests loading huge extreme Maven projects in m2e to check how it
likes it or not and how to improve it.
> One of the tests creates 1000 projects, each one being a parent of the other. When trying
to read it, Maven (and thus m2e) crashes with a StackOverflowError because it deeply recurses
on build/initParent methods.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message