Skip to content

Conversation

@flyrain
Copy link
Contributor

@flyrain flyrain commented Nov 17, 2025

To fail fast and explicitly when resolveAll() isn't called before reading the results

Checklist

  • 🛡️ Don't disclose security issues! (contact security@apache.org)
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed)
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

Copy link
Contributor

@singhpk234 singhpk234 left a comment

Choose a reason for hiding this comment

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

Thanks for fix @flyrain !

// Set when resolveAll is called
private ResolverStatus primaryResolverStatus = null;

private ResolverStatus requirePrimaryResolverStatus() {
Copy link
Contributor

Choose a reason for hiding this comment

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

minor : require gives an impression that its just doing assertion, but its additionally returning status how about this

Suggested change
private ResolverStatus requirePrimaryResolverStatus() {
private ResolverStatus safeGetPrimaryResolverStatus() {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored a bit. Thanks for the suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thx! The new code is much nicer 🙂


public PolarisResolvedPathWrapper getResolvedReferenceCatalogEntity(
boolean prependRootContainer) {
requirePrimaryResolverStatus();
Copy link
Contributor

Choose a reason for hiding this comment

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

[doubt] is just checking status not null sufficient ? or should we bake the assertion that that status != null and status = SUCCESS ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point. Removed this line to avoid any behavior change.

Copy link
Contributor

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

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

@flyrain : could you explain why "resolveAll() must be called before reading resolution results"? The PR description provides information about enforcing it, but the rationale for doing that is not very clear... at least to me 😅 Thx!

@flyrain
Copy link
Contributor Author

flyrain commented Nov 17, 2025

@flyrain : could you explain why "resolveAll() must be called before reading resolution results"? The PR description provides information about enforcing it, but the rationale for doing that is not very clear... at least to me 😅 Thx!

The result will be invalid, or null if it's not invoked. The concurrent code actually already enforce that. You can find the following code in each place reading the result, but NPE will be threw in case of resovleAll() not called. This PR is mainly to make it fail explicitly instead of a NPE.

if (primaryResolverStatus.getStatus() != ResolverStatus.StatusEnum.SUCCESS) {
   return null
}

dimas-b
dimas-b previously approved these changes Nov 17, 2025
@github-project-automation github-project-automation bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Nov 17, 2025
@dimas-b dimas-b requested a review from dennishuo November 17, 2025 19:37
Copy link
Contributor

@singhpk234 singhpk234 left a comment

Choose a reason for hiding this comment

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

LGTM thanks @flyrain !

@flyrain flyrain merged commit 415c9c0 into apache:main Nov 20, 2025
15 checks passed
@github-project-automation github-project-automation bot moved this from Ready to merge to Done in Basic Kanban Board Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants