fix: keep all profile activation keys in the cache, including inactive ones - #12728
fix: keep all profile activation keys in the cache, including inactive ones#12728waterWang wants to merge 1 commit into
Conversation
…e ones
DefaultProfileActivationContext.stop() was filtering out
false-valued entries from usedActiveProfiles and
usedInactiveProfiles before freezing the Record. This meant a
parent assembled without -Prelease stored an empty map
(usedActiveProfiles = {}), which matches ANY context —
including one where -Prelease is active. The poisoned cache
entry was then shared by every reactor module, causing
profile-injected content (plugin executions, properties,
dependencies) to silently vanish from a subset of modules.
Fix: remove the two removeIf filters so every consulted
profile key is retained, regardless of whether it evaluated
to true or false. The Record.matches() method already
correctly verifies keys it holds, so a false-valued entry
correctly prevents a mis-match.
Fixes apache#12724
See apache#12724 for full
root-cause analysis and test case.
gnodet
left a comment
There was a problem hiding this comment.
Correct, minimal fix for a real cache-key bug in profile activation context. The removeIf calls in stop() were stripping false entries from the activation maps, causing empty maps that matched any context via allMatch — letting matchesProfiles incorrectly treat contexts where a profile was consulted but inactive as equivalent to contexts where the profile was never seen.
The fix (removing those two removeIf lines) is clean and well-targeted, and the new test directly validates the cache-key distinction.
Minor nit: Missing trailing newline at end of ParentProfileCacheTest.java.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
Problem
DefaultProfileActivationContext.stop()filters outfalse-valued entries fromusedActiveProfilesandusedInactiveProfilesbefore freezing theRecord. This means a parent POM assembled without-Preleasestores an empty map (usedActiveProfiles = {}), which matches ANY context — including one where-Preleaseis active. The poisoned cache entry is then shared by every reactor module, causing profile-injected content (plugin executions, properties, dependencies) to silently vanish from a subset of modules.Root cause: the cache key is too narrow — it only records profiles that were active, not profiles that were consulted but found inactive.
Fix
Remove the two
removeIffilters so every consulted profile key is retained, regardless of whether it evaluated totrueorfalse. TheRecord.matches()method already correctly verifies keys it holds, so afalse-valued entry correctly prevents a mis-match.Test
Added
ParentProfileCacheTestwith two assertions that fail on the unpatched code and pass with the fix:-Preleasemust not be reused for a module built with-Prelease-!releasemust not be reused for a module built with-!releaseReferences
Full root-cause analysis: #12724