You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "goutamadwant (via GitHub)" <gi...@apache.org> on 2026/09/02 05:27:06 UTC
[PR] [MNG-8671] Add request trace context to derived sessions [maven]
goutamadwant opened a new pull request, #13009:
URL: https://github.com/apache/maven/pull/13009
Fixes #10420
## Description
Add `Session.withContext(RequestTrace)` so callers can create a derived Maven session with a non-null base trace context.
The scoped context is preserved across local and remote repository derivation and propagated through Resolver operations, including artifact resolution, installation, and deployment. Nested and explicit request traces restore the exact previous trace after completion.
The active trace remains thread-isolated while being visible to Maven sessions that share the same Resolver session.
## Tests
- Added coverage for context propagation, nesting, repository derivation, concurrency, and null validation.
- Added regression tests for explicit trace restoration and install/deploy propagation.
- Focused tests: 21 passed.
- `mvn --batch-mode verify`: passed.
- Core IT: 1,059 tests passed under JDK 26. The two JDK-sensitive failures were rerun under JDK 21 and all 4 test methods passed.
Following this checklist to help us incorporate your contribution quickly and easily:
- [x] This pull request addresses one issue without unrelated changes.
- [x] The description explains what the pull request does, how, and why.
- [x] The commit has a meaningful subject and body.
- [x] Unit tests cover the behavioral changes.
- [x] `mvn verify` passes.
- [ ] The complete Core IT command passed in one environment. See the JDK-specific results above.
- [x] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
- [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
[core-its]: https://maven.apache.org/core-its/core-it-suite/
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MNG-8671] Add request trace context to derived sessions [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet merged PR #13009:
URL: https://github.com/apache/maven/pull/13009
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MNG-8671] Add request trace context to derived sessions [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #13009:
URL: https://github.com/apache/maven/pull/13009#discussion_r3924312727
##########
impl/maven-impl/src/main/java/org/apache/maven/impl/AbstractSession.java:
##########
@@ -1037,12 +1058,17 @@ public PathScope requirePathScope(String id) {
@Override
public void setCurrentTrace(RequestTrace trace) {
- getTraceHolder().set(trace);
+ if (trace == context) {
+ getTraceHolder().remove();
+ } else {
+ getTraceHolder().set(trace);
+ }
}
Review Comment:
Minor hygiene nit: when `setCurrentTrace(null)` is called (e.g. in `DefaultModelBuilder`'s `PhasingExecutor` finally blocks), it takes the `else` branch and calls `getTraceHolder().set(null)` rather than `remove()`. This retains a null entry in the ThreadLocal map rather than cleaning it up — a minor concern in thread-pool scenarios.
Consider:
```suggestion
public void setCurrentTrace(RequestTrace trace) {
if (trace == context || trace == null) {
getTraceHolder().remove();
} else {
getTraceHolder().set(trace);
}
}
```
##########
impl/maven-testing/src/main/java/org/apache/maven/testing/plugin/stubs/SessionStub.java:
##########
@@ -192,6 +193,11 @@ public Session withRemoteRepositories(List<RemoteRepository> repositories) {
return null;
}
+ @Override
+ public Session withContext(RequestTrace trace) {
Review Comment:
Nit: `withContext()` returns `null` despite the `@Nonnull` contract on `Session.withContext()`. This is consistent with the existing stub pattern (`withLocalRepository()` and `withRemoteRepositories()` also return null), so it matches convention — just noting for awareness.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org