GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Enh: Allow validator factory to abstain by cstamas · Pull Request #2008 · apache/maven-resolver

Conversation

@cstamas

@cstamas cstamas commented Jul 22, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Changes:

  • allow ValidatorFactory to "abstain" and return NOOP
  • introduce alt execution path for managed dependencies (use cases varies)
  • cache validators per session

Fixes: #2007

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cstamas
Enh: Allow validator factory to abstain
a9de30f
Also, cache validators across single session.

Fixes: apache#2007
@cstamas cstamas added this to the 2.0.22 milestone Jul 22, 2026
@cstamas
cstamas requested review from gnodet and slawekjaranowski July 22, 2026 10:01
@cstamas cstamas self-assigned this Jul 22, 2026
@cstamas cstamas added the enhancement New feature or request label Jul 22, 2026
@cstamas
cstamas requested a review from kwin July 22, 2026 13:12
@cstamas
cstamas marked this pull request as ready for review July 22, 2026 13:12
@cstamas
Introduce new validator method.
c7626b0
@cstamas cstamas mentioned this pull request Jul 22, 2026
Extend re-entrancy detection for broken trace chains #2009
Merged
4 of 5 tasks
gnodet added a commit that referenced this pull request Jul 23, 2026
@gnodet @claude
Restore managed dependency validation per review feedback
7400592
Revert the managed dependency validation removal from
DefaultRepositorySystemValidator. As cstamas noted, managed deps should
remain validatable for non-Maven use cases — the proper separation
between direct and managed dependency validation belongs in PR #2008
(validateManagedDependency method).

This PR now focuses solely on session-scoped re-entrancy detection
via an AtomicInteger depth counter in session data, which covers
the broken trace chain scenario independently.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
elharo
elharo requested changes Jul 23, 2026
View reviewed changes

@elharo elharo left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tests

Is there a better signal than "null" for abstention that doesn't risk NPEs? Abstention seems equivalent to approval unless something requires some validator to approve?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread maven-resolver-spi/src/main/java/org/eclipse/aether/spi/validator/Validator.java Outdated
* that are never actually used. If a managed dependency IS matched and its coordinates are invalid, the error
* will surface naturally during version resolution or artifact resolution.
*
* @param managedDependency The managed dependency to validate, never {@code null}.

@elharo elharo Jul 23, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: begin with lower case the
no periods at end

per Oracle guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@cstamas cstamas Jul 24, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I agree with this sentiment, this javadoc method is not the single one in this PR not following that, and in this codebase this is not the single one either (in fact, whole codebase follows this style). I'd leave this change to some time, and IMO the change should be done consistently across whole codebase.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@cstamas cstamas Jul 24, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, was wrong: lowercase stands but not the "no period at end"?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gnodet
gnodet reviewed Jul 23, 2026
View reviewed changes

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overall design of the three features (abstain, managed-dependency differentiation, caching) is sound and addresses real needs. The separate validateManagedDependency path correctly avoids false positives from uninterpolated BOM property expressions — well-documented rationale.

Two implementation issues in the caching logic:

  1. Null values not cached: ConcurrentHashMap.computeIfAbsent does not store entries when the mapping function returns null. When a factory abstains (returns null), the factory is re-invoked on every subsequent validation call within the same session — contradicting the Javadoc claim that "even nulls are cached." Fix: use a sentinel object pattern (e.g., private static final Validator ABSENT = new Validator() {};) and unwrap on retrieval.

  2. System.identityHashCode as map key: System.identityHashCode is not guaranteed unique across distinct object instances. Hash collisions cause the second factory's newInstance() to never be called — it silently reuses the first factory's Validator. Since Integer.equals compares by value, two different factory instances with the same identityHashCode map to the same key. Fix: use the factory instance itself as the key (ConcurrentHashMap<ValidatorFactory, Validator>), which relies on reference equality via Object.equals.

Missing test coverage: No tests cover the three new behaviors — factory returning null to abstain, per-session caching, or managed dependencies routed to validateManagedDependency.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of gnodet

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
cstamas added 2 commits July 23, 2026 22:29
@cstamas
Merge remote-tracking branch 'upstream/master' into issue-2007
e5b25d7
@cstamas
Add PR review changes
819997e
@cstamas
cstamas requested review from elharo and gnodet July 23, 2026 21:16
gnodet
gnodet reviewed Jul 23, 2026
View reviewed changes

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The critical bugs from the previous review are properly fixed — the NOOP sentinel pattern and string-keyed Map are clean solutions. Two minor issues remain.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of gnodet

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread maven-resolver-spi/src/main/java/org/eclipse/aether/spi/validator/ValidatorFactory.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...er-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystemValidator.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

cstamas and others added 4 commits July 24, 2026 10:33
@cstamas @gnodet
Update maven-resolver-impl/src/main/java/org/eclipse/aether/internal/…
3baceec
…impl/DefaultRepositorySystemValidator.java

Co-authored-by: Guillaume Nodet <[email protected]>
@cstamas
PR comments
e1ef2b0
@cstamas
Tidy up UT
52d819d
@cstamas
Lower case
ddd50e0
@cstamas
cstamas requested a review from gnodet July 24, 2026 09:05
elharo
elharo reviewed Jul 24, 2026
View reviewed changes
Comment thread ...er-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystemValidator.java

@Inject
public DefaultRepositorySystemValidator(List<ValidatorFactory> validatorFactories) {
public DefaultRepositorySystemValidator(Map<String, ValidatorFactory> validatorFactories) {

@elharo elharo Jul 24, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public API change

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@cstamas cstamas Jul 24, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public API defined here https://maven.apache.org/resolver/api-compatibility.html
So is not. Moreover, client code should use DI, and DI protects from changes like these, and they should inject managed beans, not manually (re)construct them.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...er-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystemValidator.java
for (RemoteRepository repository : request.getRepositories()) {
for (Map.Entry<String, ValidatorFactory> entry : validatorFactories.entrySet()) {
Validator validator = newInstance(session, entry.getKey(), entry.getValue());
if (validator != ValidatorFactory.NOOP) {

@elharo elharo Jul 24, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need all these if (validator != ValidatorFactory.NOOP) checks? If it's Validator.NOOP then the validator doesn't throw any exceptions, nothing is added to the exceptions list, and we get exactly the same result. It feels cleaner to just treat Validator.NOOP like every other one.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@cstamas cstamas Jul 24, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, this is leftover from null being allowed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@cstamas cstamas Jul 24, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, am leaving it as it is not hurting. OTOH, with today's app frameworks we at least avoid busy-looping (and calling no-op method) over thousands of managed deps...

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...er-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystemValidator.java
public class DefaultRepositorySystemValidator implements RepositorySystemValidator {
private final List<ValidatorFactory> validatorFactories;
private static final Object SESSION_VALIDATORS = Keys.of(DefaultRepositorySystemValidator.class, "validators");
private final Map<String, ValidatorFactory> validatorFactories;

@elharo elharo Jul 24, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure there's a reason but I don't immediately see what the String key is here or why we need it. A comment might be helpful.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@cstamas cstamas Jul 24, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See "What is Sisu" here https://eclipse.dev/sisu/org.eclipse.sisu.inject/

This is most common technique to have injected "variations" (or qualified beans) for same (component) contract.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gnodet
gnodet approved these changes Jul 24, 2026
View reviewed changes

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All previously identified issues are properly fixed. The NOOP sentinel pattern is a clean solution for the abstain mechanism, the Javadoc is now consistent, and null enforcement is uniform across both code paths. Test coverage is solid.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of gnodet

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cstamas
cstamas merged commit f164aa9 into apache:master Jul 24, 2026
20 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@cstamas
cstamas deleted the issue-2007 branch July 24, 2026 12:02
@gnodet gnodet mentioned this pull request Aug 8, 2026
Fix compilation error in DefaultRepositorySystemReentrancyTest #2047
Merged
2 of 3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@elharo elharo elharo requested changes
@gnodet gnodet gnodet approved these changes
@slawekjaranowski slawekjaranowski Awaiting requested review from slawekjaranowski
@kwin kwin Awaiting requested review from kwin

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@cstamas cstamas

Labels

enhancement New feature or request

Projects

None yet

Milestone

2.0.22

Development

Successfully merging this pull request may close these issues.

ValidatorFactory should be allowed to return null

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@cstamas @gnodet @elharo
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.