gnodet opened a new pull request, #1980:
URL: https://github.com/apache/maven-resolver/pull/1980
## Summary
PR #1957 (commit e29d0cda) added re-entrancy detection to
`DefaultRepositorySystem` by stamping a `REPOSITORY_SYSTEM_CALL` marker into
the `RequestTrace` chain. However, it placed the marker as the trace **tip
data**, replacing whatever was there before (typically an `Artifact` set by
Maven core).
Plugins that walk the `RequestTrace` chain and cast `getData()` to their
expected type without an `instanceof` check (e.g. `pgpverify-maven-plugin`,
`maven-gpg-plugin`) get a `ClassCastException`:
```
ClassCastException: class
org.eclipse.aether.internal.impl.DefaultRepositorySystem$1
cannot be cast to class org.apache.maven.artifact.Artifact
```
This is a regression — both `maven-artifact-plugin` and `maven-gpg-plugin`
were passing with rc-5 and are now failing with resolver 2.0.21-SNAPSHOT.
## Fix
Instead of placing the marker as the trace tip, insert it **one level
deeper** and re-attach the original tip data on top:
```java
private static RequestTrace stampReentrancyMarker(RequestTrace currentTrace)
{
RequestTrace markerTrace = RequestTrace.newChild(currentTrace,
REPOSITORY_SYSTEM_CALL);
return currentTrace != null
? RequestTrace.newChild(markerTrace, currentTrace.getData())
: markerTrace;
}
```
The `isReentrant()` method is unaffected — it walks the full chain and will
still find the marker.
## Test plan
- [x] Added `outerCallPreservesOriginalTraceData` test verifying that
original trace data remains at the tip after stamping
- [x] Added `outerCallWithNullTraceStillStampsMarker` test verifying the
null-trace case still works correctly for re-entrancy detection
- [x] All existing re-entrancy tests continue to pass
- [x] Full `maven-resolver-impl` test suite passes (454 tests, 0 failures)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]