Skip to content

fix: avoid mutating settings when showing passwords - #439

Merged
slachiewicz merged 1 commit into
apache:masterfrom
efegokdemir:codex/issue-385-copy-settings
Oct 27, 2026
Merged

slachiewicz merged 1 commit into
apache:masterfrom
efegokdemir:codex/issue-385-copy-settings

Conversation

@efegokdemir

Copy link
Copy Markdown
Contributor

Summary

help:effective-settings -DshowPasswords=true currently passes Maven's live Settings object to cleanup code, which replaces each profile's properties with a sorted copy. This mutates shared Maven state during report generation.

Changes

  • Always serialize a defensive settings copy, including when passwords are shown.
  • Deep-copy profile objects and their properties so cleanup remains isolated from the caller.
  • Add a regression test for the showPasswords path.

Testing

  • mvn -B -DskipITs -Dspotless.check.skip=true -Dspotless.apply.skip=true test — passed (31 tests).
  • JAVA_HOME=/opt/homebrew/Cellar/openjdk@21/21.0.12.1/libexec/openjdk.jdk/Contents/Home PATH="$JAVA_HOME/bin:$PATH" mvn -B spotless:check — passed.
  • git diff --check — passed.
  • The focused regression test failed on the unchanged implementation and passed after the fix.

Fixes #385

Comment on lines +193 to +202
List<Profile> clonedProfiles = new ArrayList<>(settings.getProfiles().size());
for (Profile profile : settings.getProfiles()) {
Profile clonedProfile = profile.clone();
Properties clonedProperties = new Properties();
clonedProperties.putAll(profile.getProperties());
clonedProfile.setProperties(clonedProperties);
clonedProfiles.add(clonedProfile);
}
clone.setProfiles(clonedProfiles);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It is for this PR?

The same is in: #440

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The profile copy is shared with #440. #439 needs it too: cleanSettings changes profile properties even with showPasswords=true, so copying the settings without the profiles still mutates the originals. Once #440 lands, #439 can be rebased to leave the showPasswords change and its regression.

@slachiewicz slachiewicz added the bug Something isn't working label Oct 27, 2026
@slachiewicz
slachiewicz force-pushed the codex/issue-385-copy-settings branch from 3e9e4e8 to eae3b79 Compare October 27, 2026 20:56
@github-actions

Copy link
Copy Markdown

⚠️ License declaration missing

The pull request description must contain at least one of the following lines with a checked box ([x]):

- [ ] I hereby declare this contribution to be licensed under the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
- [ ] I hereby declare that I have filed an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).

This comment will be hidden automatically once the description is fixed.

@slachiewicz
slachiewicz merged commit 75a0df5 into apache:master Oct 27, 2026
18 of 19 checks passed
@github-actions github-actions Bot added this to the 3.5.3 milestone Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EffectiveSettingsMojo mutates original Settings when showPasswords=true

3 participants