gnodet commented on PR #14133:
URL: https://github.com/apache/maven/pull/14133#issuecomment-7315578449

   <!-- forgebot-watermark -->
   Fixed the CI failures with a commit on the branch.
   
   **Root cause:** `addAttachedArtifact()`, `getAttachedArtifacts()` and 
`setAttachedArtifacts()` unconditionally called `mutableProject.project()`, 
which throws NPE when the project hasn't been registered in a session yet (i.e. 
when `DefaultSession.getProject(MavenProject)` hasn't been called for it). This 
affected:
   - Tests that create bare `new MavenProject()` and call artifact methods 
directly (`DefaultMavenTest`, `ReactorReaderTest`, 
`ConsumerPomArtifactTransformerTest`, `LifecycleExecutorTest`)
   - Full-build tests (`MavenLifecycleParticipantTest`) where 
`ConsumerPomArtifactTransformer.injectTransformedArtifacts()` is called before 
the project is registered in the v4 session
   
   **Fix:** Guard all three methods with `mutableProject.projectOrNull() != 
null`. When the project is uninitialized, fall back to a 
`legacyAttachedArtifacts` list (restoring the old behavior). When the project 
is later registered in the session via `DefaultSession.getProject()`, any 
accumulated legacy artifacts are migrated into `MutableProject` and the legacy 
list is cleared.


-- 
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