Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-6398

Multithread Build Hangs Execution with sonar:sonar goal when Aggregator POM references a Child Module as its Parent

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Incomplete
    • 3.0.5, 3.2.5, 3.3.9, 3.5.3
    • None
    • Core
    • Java: 1.8.0_152 (Oracle), MacOS 10.13.4, Locale: en_US, Encoding: UTF-8

    Description

      Problem Statement

      I have an Aggregator POM whose Parent POM is also one of its child Modules. When I run a multi-thread Maven build with normal goals, such as 'clean install' it works as expected; The Parent module builds first followed by the Aggregator.

      However when running 'mvn sonar:sonar -T 2' the build hangs indefinitely (from org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905).

      Sample Project

      Attached.

      Layout

      /pom.xml

      /parent/pom.xml

      Reproducing the Issue

      A normal multi-threaded build should work as expected: mvn clean install -T 2

      But when running sonar goal, it hangs indefinitely: mvn sonar:sonar -T 2 (This can also be reproduced with mvn clean install sonar:sonar -T 2, in which case it hangs immediately after building and installing both projects)

      DANIJOH2-M-C5DB:deadlock-sample danijoh2$ mvn sonar:sonar -T 2
      [INFO] Scanning for projects...
      [INFO] ------------------------------------------------------------------------
      [INFO] Reactor Build Order:
      [INFO]
      [INFO] parent [pom]
      [INFO] aggregator [pom]
      [INFO]
      [INFO] Using the MultiThreadedBuilder implementation with a thread count of 2
      <process is now hung>

      Running the same build with a single thread works fine: mvn sonar:sonar

      Stack Trace of Hanging Maven Process

      Attached.

      Summary

      I saw the same behavior with Maven 3.0.5, 3.2.3, and 3.3.9, as well with sonar-maven-plugin 3.0 and 3.3.0.603 with the same results. From the stack trace, it seems Maven itself is hung (not deadlocked though), and while it may be caused by the Sonar plugin, it seems the fix likely needs to come from Maven.

      If I make the aggregator itself the parent (and get rid of the parent module entirely) then it works fine. The problem with this approach, is in our project we are also creating aggregated site reports for our project, which if I recall correctly when I tried this last time, the aggregated reports were not always working as expected when the aggregator POM builds before its modules.

      Attachments

        1. maven-hanging-stack.txt
          5 kB
          Daniel Johnson
        2. maven-multithread-hanging-sample.zip
          2 kB
          Daniel Johnson

        Issue Links

          Activity

            People

              Unassigned Unassigned
              hankolerd Daniel Johnson
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: