Skip to content
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

Make ErrorAction.equals a public API #289

Merged
merged 1 commit into from
Jul 6, 2023

Conversation

dwnusbaum
Copy link
Member

@dwnusbaum dwnusbaum commented Jul 3, 2023

ErrorAction.findOrigin is useful, but can be prohibitively slow in complex Pipelines with a lot of errors, as it scans the entire flow graph. In particular, I have a case where I only need to know whether a specific ErrorAction represents an original or re-thrown error, and findOrigin is currently the only way to get access to the ErrorId equality logic.

This PR exposes ErrorAction.equals so that other plugins can check error originality using more limited scans in cases where finding the true origin of an error is unnecessary and too slow.

Testing done

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@dwnusbaum dwnusbaum requested review from jglick and a team July 3, 2023 18:51
@@ -165,7 +167,8 @@ public String getUrlName() {
* {@link Throwable#equals} might not be reliable if the program has resumed
* and stuff is deserialized.
*/
private static boolean equals(Throwable t1, Throwable t2) {
@Restricted(Beta.class)
public static boolean equals(Throwable t1, Throwable t2) {
Copy link
Member Author

Choose a reason for hiding this comment

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

For my particular case, I could instead create a new public static boolean isRethrown(FlowNode node) method that checks whether the ErrorAction on the associated FlowNode was also thrown by one of its immediate parents, but exposing equals directly does not seem particularly problematic to me and may be useful in other cases.

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Makes sense.

@jglick jglick merged commit 41b0279 into jenkinsci:master Jul 6, 2023
@dwnusbaum dwnusbaum deleted the erroraction-equals branch July 6, 2023 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants