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


##########
impl/maven-core/src/main/java/org/apache/maven/internal/transformation/impl/ConsumerPomArtifactTransformer.java:
##########
@@ -89,7 +89,11 @@ public void 
injectTransformedArtifacts(RepositorySystemSession session, MavenPro
                     : Files.createTempFile(CONSUMER_POM_CLASSIFIER + "-", 
".pom");
             deferDeleteFile(consumer);
 
-            project.addAttachedArtifact(createConsumerPomArtifact(project, 
consumer, session));
+            boolean alreadyAttached = project.getAttachedArtifacts().stream()

Review Comment:
   **Low:** The idempotency check here is placed after the temp file creation 
and `deferDeleteFile()` registration (lines 87-90). On repeated invocations 
where the consumer POM is already attached, a new temp file is created on disk, 
registered for deferred deletion, but never used.
   
   Consider hoisting the `alreadyAttached` check to the top of the `if 
(Features.consumerPom(...))` block, before creating the temp file. This would 
avoid unnecessary I/O on repeated invocations. The files are cleaned up by 
`@PreDestroy doDeleteFiles()` so this is not a leak, just wasteful work.



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