Sitelet https://github.com/apache/maven/pull/13154
Skip to content

Lower-case the OS family before matching it against the family names (backport of #13152 to maven-4.0.x) - #13154

Merged
gnodet merged 1 commit into
apache:maven-4.0.xfrom
gnodet:backport/13152-to-4.0.x
Sep 16, 2026
Merged

gnodet merged 1 commit into
apache:maven-4.0.xfrom
gnodet:backport/13152-to-4.0.x

Conversation

@gnodet

@gnodet gnodet commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Backport of #13152 to the maven-4.0.x branch.

Cherry-pick of 5d36a54, applied cleanly with no conflicts.

…pache#13152)

* Lower-case the OS family before matching it against the family names

The Maven 3 activator lower-cases activation/os/family before handing it
to Os.isFamily (0456c7c, "Caplital OS name can not activate profile"),
as it does for name and arch. The Maven 4 activator lower-cases name and
arch but passes family through untouched.

Os.isFamily switches on the family string against lower-case constants
such as "winnt", "unix" and "dos"; anything that does not match falls
through to the default branch, which is a plain
actualOsName.contains(family). Families whose name is a substring of the
OS name, like "Mac" on "mac os x", still work by accident, which is why
the existing capital-name test did not catch this. The ones that rely on
the switch do not: <family>WinNT</family> no longer activates on
Windows, and <family>Mac</family> no longer activates on a JDK reporting
os.name=darwin.

Add the toLowerCase call so the family follows the same rule as the
other three fields, and cover the two cases above.

* Add negation test for capitalised OS family

---------

Co-authored-by: Guillaume Nodet <gnodet@gmail.com>
@gnodet gnodet added this to the 4.0.0-rc-7 milestone Sep 16, 2026

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Clean backport of #13152. The fix is correct: Os.isFamily() uses all-lowercase constants in its switch (e.g. FAMILY_NT = "winnt", FAMILY_MAC = "mac") and would silently fall through to the default branch for mixed-case input like WinNT, producing wrong matching semantics. Lowercasing with Locale.ENGLISH before the family lookup is the right fix. The ! negation prefix is unaffected since ! is not modified by case conversion. Tests cover positive/negative matches and the negated case (!WinNT) — sufficient coverage.

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

@gnodet gnodet added bug Something isn't working backport labels Sep 16, 2026
@gnodet
gnodet merged commit 1249af4 into apache:maven-4.0.x Sep 16, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants