maven-issues mailing list archives

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


Mickael Istria commented on MNG-6563:

Here is the code I use to generate the project
  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);
      File pom = new File(projectDir, "pom.xml");
      try (PrintStream content = new PrintStream(pom);) {
        content.println("  <modelVersion>4.0.0</modelVersion>");
        content.println("  <groupId>org.eclipse.m2e.core.tests.hierarchy</groupId>");
        content.println("  <artifactId>pNUMBER</artifactId>".replace("NUMBER",
        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>");
    return poms;
then, invoking " 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:
>             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

View raw message