Fix: preserve original trace data when stamping re-entrancy marker#1980
Merged
Conversation
The re-entrancy detection added in e29d0cd stamps a marker object 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 trace chain and cast getData() to Artifact (e.g. pgpverify-maven-plugin) get a ClassCastException when they hit the marker object. This fix inserts the marker one level deeper in the trace chain and re-attaches the original tip data on top, so existing code that reads getData() continues to find the expected object. The isReentrant() method is unaffected because it walks the full chain and will still find the marker. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cstamas
approved these changes
Jul 18, 2026
There was a problem hiding this comment.
Pull request overview
This PR fixes a regression in DefaultRepositorySystem re-entrancy detection by stamping the REPOSITORY_SYSTEM_CALL marker into the RequestTrace chain without overwriting the original trace tip data (which is commonly an Artifact provided by Maven core). This avoids downstream ClassCastExceptions in plugins that assume the trace tip’s getData() is of a specific type.
Changes:
- Introduce
stampReentrancyMarker(RequestTrace)to insert the marker below the trace tip while preserving the original tip data. - Update all relevant public
DefaultRepositorySystementrypoints to usestampReentrancyMarker(...)instead of stamping the marker as the trace tip. - Add tests covering preservation of original trace tip data and the null-trace stamping/re-entrancy behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystem.java | Replace direct marker stamping with stampReentrancyMarker(...) to preserve original RequestTrace tip data. |
| maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultRepositorySystemReentrancyTest.java | Add regression tests for trace tip preservation and null-trace marker stamping behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+279
to
+282
| // 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"); | ||
| } |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet
marked this pull request as ready for review
July 19, 2026 16:32
cstamas
approved these changes
Jul 19, 2026
|
@gnodet Please assign appropriate label to PR according to the type of change. |
gnodet
added a commit
to gnodet/maven-resolver
that referenced
this pull request
Jul 20, 2026
gnodet
added a commit
to gnodet/maven
that referenced
this pull request
Jul 20, 2026
Includes fix for trace marker regression (apache/maven-resolver#1980) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR #1957 (commit e29d0cd) added re-entrancy detection to
DefaultRepositorySystemby stamping aREPOSITORY_SYSTEM_CALLmarker into theRequestTracechain. However, it placed the marker as the trace tip data, replacing whatever was there before (typically anArtifactset by Maven core).Plugins that walk the
RequestTracechain and castgetData()to their expected type without aninstanceofcheck (e.g.pgpverify-maven-plugin,maven-gpg-plugin) get aClassCastException:This is a regression — both
maven-artifact-pluginandmaven-gpg-pluginwere 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:
The
isReentrant()method is unaffected — it walks the full chain and will still find the marker.Test plan
outerCallPreservesOriginalTraceDatatest verifying that original trace data remains at the tip after stampingouterCallWithNullTraceStillStampsMarkertest verifying the null-trace case still works correctly for re-entrancy detectionmaven-resolver-impltest suite passes (454 tests, 0 failures)🤖 Generated with Claude Code