gnodet commented on code in PR #13406:
URL: https://github.com/apache/maven/pull/13406#discussion_r4241265137


##########
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultProfileInjector.java:
##########
@@ -103,6 +104,66 @@ public void mergeBuildBase(BuildBase.Builder builder, 
BuildBase target, BuildBas
             mergeBuildBase(builder, target, source, true, 
Collections.emptyMap());
         }
 
+        @Override
+        protected void mergeModelBase_Properties(
+                ModelBase.Builder builder,
+                ModelBase target,
+                ModelBase source,
+                boolean sourceDominant,
+                Map<Object, Object> context) {
+            Map<String, String> src = source.getProperties();
+            Map<String, String> tgt = target.getProperties();
+            Map<String, String> merged = new LinkedHashMap<>(tgt.size() + 
src.size() * 2);
+            if (sourceDominant) {
+                merged.putAll(tgt);
+                merged.putAll(src);
+            } else {
+                merged.putAll(src);
+                merged.putAll(tgt);
+            }
+
+            if (src.isEmpty()) {
+                builder.properties(merged);
+                builder.location(
+                        "properties",
+                        InputLocation.merge(
+                                target.getLocation("properties"), 
source.getLocation("properties"), sourceDominant));
+                return;
+            }
+
+            if (source instanceof Profile profile) {
+                String profileId = profile.getId();
+                if (profileId != null && !profileId.isEmpty()) {
+                    String prefix = "profile." + profileId + ".";
+                    // Note: Profile IDs containing dots (e.g., "foo.bar") may 
cause key collisions
+                    // if another profile (e.g., "foo") defines a property 
that shares the same prefix
+                    // (e.g., "bar.myprop"). In such cases, last-write-wins 
applies. Profile IDs without

Review Comment:
   💡 **Suggestion:** The comment correctly documents the last-write-wins 
side-effect for dot-ID collisions, but 
`testProfileScopePropertiesDotIdBehavior` only verifies that the expected keys 
are generated — it doesn't actually exercise the collision path (e.g., profile 
`foo.bar` with property `myprop` vs profile `foo` with property `bar.myprop`, 
both mapping to `profile.foo.bar.myprop`). Consider adding a test that:
   1. Creates two profiles whose IDs + property names produce the **same** 
scoped key.
   2. Asserts which value wins (last-write-wins / injection order).
   
   This would lock down the documented behaviour and prevent silent regressions.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to