apache / apache/maven-surefire

`surefire.forkNumber` collision when running Maven with parallel modules

Open
#3,233 6 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
461
Forks
588
Avg merge
1d 8h
Merged PRs (30d)
19

Description

### 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:
```

org.apache.maven.plugins
maven-surefire-plugin
3.5.3

4

-ea -Xmx1500m -XX:+HeapDumpOnOutOfMemoryError
-Dsurefire.forkNumber=${surefire.forkNumber}

false

```
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?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported configuration with Maven parallel execution (-T 2 verify), forkCount 4, and reuseForks false, then trace how surefire.forkNumber is assigned across concurrently built modules. Compare the overlapping fork identifiers in the supplied logs and establish the expected uniqueness scope before deciding what behavior should be changed or documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.