Copilot commented on code in PR #1980:
URL: https://github.com/apache/maven-resolver/pull/1980#discussion_r3610381268
##########
maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultRepositorySystemReentrancyTest.java:
##########
@@ -251,4 +252,53 @@ void independentCallsEachValidate() throws Exception {
assertEquals(2, validationCount.get(), "Two independent calls should
each validate");
}
+
+ @Test
+ void outerCallPreservesOriginalTraceData() throws Exception {
+ // Plugins (e.g. pgpverify-maven-plugin) walk the RequestTrace chain
and cast
+ // getData() to Artifact without an instanceof check. The re-entrancy
marker
+ // must NOT replace the original tip data — it should be inserted
below it.
+ Object originalData = new Object();
+ RequestTrace originalTrace = RequestTrace.newChild(null, originalData);
+
+ VersionRequest request = new VersionRequest();
+ request.setArtifact(new DefaultArtifact("g:a:1"));
+ request.setRepositories(Collections.emptyList());
+ request.setTrace(originalTrace);
+
+ system.resolveVersion(session, request);
+
+ // After the call, the trace tip should still expose the original data
+ RequestTrace resultTrace = request.getTrace();
+ assertNotNull(resultTrace, "Request should have a trace after the
call");
+ assertSame(
+ originalData,
+ resultTrace.getData(),
+ "Trace tip data should be the original data, not the
re-entrancy marker");
+
+ // The marker should be present deeper in the chain (parent of the tip)
+ RequestTrace parent = resultTrace.getParent();
+ assertNotNull(parent, "Trace should have a parent containing the
re-entrancy marker");
+ }
Review Comment:
`outerCallPreservesOriginalTraceData` claims the parent contains the
re-entrancy marker, but it only asserts the parent is non-null. This can let
regressions slip through where some other parent node is present but the marker
is missing/relocated. Consider asserting that the immediate parent is the
RepositorySystem marker (e.g., via its `toString()` value).
--
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]