gnodet-bot commented on code in PR #12695:
URL: https://github.com/apache/maven/pull/12695#discussion_r4050905903
##########
api/maven-api-core/src/main/java/org/apache/maven/api/Session.java:
##########
@@ -46,6 +46,20 @@
@ThreadSafe
public interface Session extends ProtoSession {
+ /**
+ * Returns the environment context of this build: the flags, properties,
and
+ * platform settings that were active when the session started.
+ *
+ * <p>The returned instance is immutable and captures a snapshot of the
invocation
+ * context (offline mode, user properties, selected projects, etc.). It is
the same
Review Comment:
**[Medium, RERAISED] Javadoc says "It is the same object recorded in the
structured build report" — but it is not.**
`DefaultSession.buildEnvironment()` calls
`BuildReportCollector.buildEnvironment(getMavenSession())` — a static method
that constructs a **fresh** `DefaultBuildEnvironment` on every call, reading
system properties and iterating user properties to redact sensitive keys. There
is no caching.
The `BuildReport.environment()` snapshot was captured at `SessionStarted`.
Each call to `Session.buildEnvironment()` constructs an independent object.
They may even differ if system properties change mid-build.
Fix: either cache the result in `DefaultSession` (one-time lazy init) and
update the Javadoc to say "same object", or remove the "same object" claim and
say "equivalent snapshot".
--
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]