Skip to content

fix: implement Node.getRepository() via local repository manager lookup - #13153

Merged
gnodet merged 2 commits into
apache:masterfrom
gnodet:fix/node-repository-impl
Sep 16, 2026
Merged

gnodet merged 2 commits into
apache:masterfrom
gnodet:fix/node-repository-impl

Conversation

@gnodet

@gnodet gnodet commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements Node.getRepository(), which previously always threw UnsupportedOperationException.

The implementation queries the local repository manager — a pure disk lookup with no network I/O — to determine which remote repository the artifact was originally downloaded from. This information is tracked by the local repo manager in .repositories tracking files alongside each cached artifact.

Returns Optional.empty() for:

  • Root nodes with no artifact
  • Nodes with no candidate repositories (e.g. local installs)
  • Artifacts that were locally installed (not downloaded from a remote)

Changes

  • DefaultNode.getRepository(): replaces UnsupportedOperationException with a LocalRepositoryManager.find()-based implementation
  • Node.java: adds missing @return Javadoc
  • DefaultNodeTest: four new tests covering the happy path, the not-found case, no-artifact (root node), and empty-repos cases

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The implementation is correct and the four tests cover the key branches. Two small items worth addressing before merge.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review after 3ce87eeed5: both prior findings addressed.

  • ✅ Javadoc summary sentence updated to match the @return tag (the narrow "downloaded from" phrasing is gone).
  • ✅ node.getRepositories() captured into repos and used consistently — no double-call.

Implementation is correct: lrm.find() is the right mechanism, the guard conditions are complete (null artifact, empty repos list), and Optional.ofNullable(result.getRepository()) correctly handles the locally-installed / not-found case. Four tests cover all branches. Ready to merge.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet gnodet added this to the 4.1.0 milestone Sep 16, 2026
@gnodet gnodet added enhancement New feature or request backport-to-4.0.x labels Sep 16, 2026
@gnodet
gnodet requested review from ascheman and cstamas September 16, 2026 13:33
@gnodet
gnodet merged commit ada2740 into apache:master Sep 16, 2026
20 checks passed
@gnodet
gnodet deleted the fix/node-repository-impl branch October 26, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants