gnodet commented on PR #12406: URL: https://github.com/apache/maven/pull/12406#issuecomment-4880748318
## Follow-up: same GAPV vs GAV inconsistency in `DefaultModelBuilder.java` (line 1944) The `readAsParentModel()` method has two paths that both call `addActivePomProfiles()`, but they use different key formats for the same parent model: | Path | Line | Key format | Code | |------|------|-----------|------| | **Cache miss** | 1961 | **GAV** ✅ | `ModelProblemUtils.toId(model)` → `g:a:v` | | **Cache hit** | 1944 | **GAPV** ❌ | `cached.model().getId()` → `g:a:p:v` | The cache-miss path was already fixed (the comment on line 1960 even says *"Use ModelProblemUtils.toId() to get groupId:artifactId:version format (without packaging)"*), but the cache-hit path on line 1944 was missed — it still calls `Model.getId()` which includes packaging. ### Practical impact When multiple child projects share the same parent: 1. **Child A** resolves parent P first → cache miss → P's profiles stored under GAV key (`org.example:parent:1.0`) 2. **Child B** resolves parent P second → cache hit → P's profiles stored under GAPV key (`org.example:parent:pom:1.0`) So in `DefaultProjectBuilder` at line 807, when it iterates `profilesByModel` and calls `setInjectedProfileIds(entry.getKey(), ...)`, the source label for the same parent's profiles would be different depending on whether the child happened to be first or second to resolve it. Non-deterministic — same bug class as this PR. ### Suggested fix One-liner on line 1944 of `DefaultModelBuilder.java`: ```java // Before (GAPV): addActivePomProfiles(cached.model().getId(), cached.activatedProfiles()); // After (GAV): addActivePomProfiles(ModelProblemUtils.toId(cached.model()), cached.activatedProfiles()); ``` `ModelProblemUtils` is already imported and used in the same file. -- 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]
