Skip to content

surefire.forkNumber collision when running Maven with parallel modules #3233

@vladilm

Description

@vladilm

Affected version

3.5.3

Bug description

When running Maven with parallel execution enabled (-T 2 verify), multiple modules are built and tested concurrently. We are using the maven-surefire-plugin with multiple forks configured:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>3.5.3</version>
  <configuration>
    <forkCount>4</forkCount>
    <argLine>
      -ea -Xmx1500m -XX:+HeapDumpOnOutOfMemoryError
      -Dsurefire.forkNumber=${surefire.forkNumber}
    </argLine>
    <reuseForks>false</reuseForks>
  </configuration>
</plugin>

The project consists of multiple modules, but test forks appear to clash across modules. Specifically, different modules start test forks with the same fork identifier (e.g., fork-1) at overlapping times.

Wed Dec 17 11:08:39 UTC 2025 -------------Surefire TestDB fork-1 in `server-tests` started--------------
Wed Dec 17 11:38:00 UTC 2025 -------------Surefire TestDB fork-1 in `token-tests` started--------------
Wed Dec 17 11:38:21 UTC 2025 -------------Surefire TestDB fork-1 in `token-test` finished--------------
Wed Dec 17 11:39:49 UTC 2025 -------------Surefire TestDB fork-1 in `server-tests` finished--------------

Is this behavior expected?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions