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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]