Skip to content

MNG-8725: Support max thread configuration - #13229

Merged
gnodet merged 1 commit into
apache:masterfrom
harshab054:mng-8725-max-threads
Sep 23, 2026
Merged

gnodet merged 1 commit into
apache:masterfrom
harshab054:mng-8725-max-threads

Conversation

@harshab054

@harshab054 harshab054 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the Core IT successfully.

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@gnodet gnodet added this to the 4.1.0 milestone Sep 21, 2026

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The max keyword works correctly in the deprecated compat/ path and the modern impl/ path, and the MavenCli tests are thorough. However, there is a test coverage gap in the production code path that needs to be addressed.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet gnodet added the enhancement New feature or request label Sep 21, 2026

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test coverage gap flagged in my previous review is now fixed — LookupInvokerTest.java is thorough and correctly exercises all calculateDegreeOfConcurrency paths on the production code path, including max/MAX/Max, error cases, and the boundary message assertion.

One remaining gap: the public API Javadoc is out of sync.

MavenOptions.threads() Javadoc — not updated

api/maven-api-cli/src/main/java/org/apache/maven/api/cli/mvn/MavenOptions.java line 164:

// current
@return an {@link Optional} containing the number of threads (or "1C" for one thread per CPU core), or empty if not specified

// should be
@return an {@link Optional} containing the number of threads (e.g. {@code 4} for an integer,
  {@code 2C} or {@code 2.5C} for a CPU multiplier, or {@code max} for available processors minus 1,
  minimum 1), or empty if not specified

This is the interface that embedders read to understand what values threads() can return. The PR correctly updates the two CLI help strings (CLIManager.java and CommonsCliMavenOptions.java) but misses the API-level contract. Since MavenOptions is the SPI boundary, this update belongs in the same PR.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both previous findings are now addressed:

  • ✅ Test coverage for LookupInvoker.calculateDegreeOfConcurrency — LookupInvokerTest.java exercises all paths including case-insensitive max/MAX/Max, boundary values, all error cases, and verifies the error message mentions 'max'.
  • ✅ MavenOptions.threads() Javadoc — updated to document the max keyword, the CPU-1 semantics, and the minimum-1 floor.

Implementation is correct and consistent: LookupInvoker and MavenCli are byte-for-byte identical on the max branch. Single-CPU edge case handled correctly (Math.max(1, 0) = 1).

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

- Add 'max' keyword to -T/--threads option: resolves to availableProcessors-1, minimum 1, case-insensitive
- Update both LookupInvoker (Maven 4.x production path) and MavenCli (compat/deprecated path) identically
- Update CLIManager and CommonsCliMavenOptions option descriptions to document the new keyword
- Update MavenOptions Javadoc with full format summary including 'max'
- Add LookupInvokerTest covering 'max', 'MAX', 'Max', numeric, multiplier, and all invalid-input cases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants