gnodet opened a new pull request, #1957:
URL: https://github.com/apache/maven-resolver/pull/1957

   ## Summary
   
   Maven 4's `ArtifactDescriptorReader` → `ModelBuilder` → `ModelResolver` 
chain re-enters `RepositorySystem` during `collectDependencies`. This breaks 
the resolver's single-crossing contract:
   
   - **Validation rejects intermediate state**: `MavenValidator` (registered 
via the `ValidatorFactory` SPI) rejects uninterpolated `${...}` expressions 
that are valid intermediate state in transitive POMs during model building
   - **Artifact decorators run redundantly**: decorators applied on inner calls 
corrupt the resolution result
   - **Reported as**: [MAVEN 
#12474](https://github.com/apache/maven/issues/12474) — `Invalid Collect 
Request: null`
   
   ### How it works
   
   On the **outermost** call to any `RepositorySystem` public method, a 
sentinel marker is stamped into the request's `RequestTrace`. On **re-entry** 
(whether on the same thread or a pool thread), `isReentrant()` walks the trace 
ancestry — if the marker is found, validation and decoration are skipped.
   
   This leverages the existing `RequestTrace` infrastructure which is already 
propagated across threads by callers (Maven's model builder explicitly copies 
traces to pool threads via `session.setCurrentTrace(trace)`), requiring **no 
ThreadLocal or session-scoped state**.
   
   ### Changes
   
   - `DefaultRepositorySystem`: all public resolution methods check 
`isReentrant(trace)` before validating/decorating
   - `readArtifactDescriptor`: additionally skips artifact decoration on 
re-entry
   - Methods without trace-bearing requests (`install`, `deploy`, 
`newResolutionRepositories`, `newDeploymentRepository`, 
`flattenDependencyNodes`) always validate — they are terminal operations that 
don't participate in re-entrancy
   - New test class `DefaultRepositorySystemReentrancyTest` with 5 tests 
covering:
     - Outermost calls run validation
     - Re-entrant calls skip validation
     - Re-entrant calls allow uninterpolated expressions (the bug scenario)
     - Re-entrant `readArtifactDescriptor` skips decoration
     - Independent calls each validate independently
   
   ## Test plan
   
   - [x] All 445 existing tests pass in `maven-resolver-impl`
   - [x] 5 new re-entrancy tests pass
   - [ ] CI build passes
   - [ ] Integration test with Maven 4 against the reproducer from #12474
   
   🤖 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]

Reply via email to