-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(qsync): NPE in "Add to project" panel action #6967
Conversation
A comment contains a warning that there should be at least two packages found in order to provide user a choice. However in some cases there is only a single package to add. For this reason, we stop the lookup if it reaches project root, but we don't add a package automatically, so a user can always reject the change. closes bazelbuild#6966
do { | ||
cancellationCheck.run(); | ||
packages = runQuery(forPath); | ||
if (!packages.isEmpty()) { | ||
candidates.add(new CandidatePackage(forPath, packages.size())); | ||
} | ||
forPath = forPath.getParent(); | ||
} while (candidates.size() < 2 && packages.size() < 2); | ||
} while (candidates.size() < 2 && packages.size() < 2 && forPath != null); |
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.
forPath != null
this could become an infinite loop
Returns the parent path, or null if this path does not have a parent.
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.
what do you mean?
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.
it's a Path
, running .getParent on it must end with a null eventually
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.
oh, my bad, I'm so sorry about that
do { | ||
cancellationCheck.run(); | ||
packages = runQuery(forPath); | ||
if (!packages.isEmpty()) { | ||
candidates.add(new CandidatePackage(forPath, packages.size())); | ||
} | ||
forPath = forPath.getParent(); | ||
} while (candidates.size() < 2 && packages.size() < 2); | ||
} while (candidates.size() < 2 && packages.size() < 2 && forPath != null); |
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.
oh, my bad, I'm so sorry about that
A comment contains a warning that there should be at least two packages found in order to provide user a choice. However in some cases there is only a single package to add.
For this reason, we stop the lookup if it reaches project root, but we don't add a package automatically, so a user can always reject the change.
closes #6966
qsync-add-to-project.mov
Checklist
Please note that the maintainers will not be reviewing this change until all checkboxes are ticked. See
the Contributions section in the README for more
details.
Discussion thread for this change
Issue number:
<please reference the issue number or url here>
Description of this change