Skip to content

Fix incorrect path resolution for system profile under WOW64 (x86) redirection#405

Open
fp024 wants to merge 1 commit intoapache:masterfrom
fp024:dev-2026-03-09
Open

Fix incorrect path resolution for system profile under WOW64 (x86) redirection#405
fp024 wants to merge 1 commit intoapache:masterfrom
fp024:dev-2026-03-09

Conversation

@fp024
Copy link
Contributor

@fp024 fp024 commented Mar 8, 2026

When MAVEN_M2_PATH points to a Windows system profile path (e.g., C:\Windows\System32\config\systemprofile\.m2),
running under an x86 (WOW64) process causes the path to be redirected to C:\Windows\SysWOW64\config\systemprofile\.m2.
In this case, (Get-Item -Path $MAVEN_M2_PATH -Force).Target returns $null instead of an array.

The previous code accessed .Target[0] directly, which throws an error when .Target is $null under an x86 process.

This fix stores .Target in a variable first and checks its type before indexing.


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 integration tests successfully (mvn -Prun-its verify).

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.

@fp024 fp024 changed the title Fix null Target index error under strict mode for system profile path Fix incorrect path resolution for system profile under WOW64 (x86) redirection Mar 9, 2026
@fp024
Copy link
Contributor Author

fp024 commented Mar 11, 2026

Hi,
Verified the behavior before and after the fix by installing Jenkins 2.541.2 on a Windows Server 2022 x64 180-day evaluation edition.

Please take a look. Thank you. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant