Skip to content

Commit

Permalink
Optimization along the lines of c27b80b
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed May 16, 2024
1 parent 15024e3 commit fd98329
Showing 1 changed file with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,24 +185,25 @@ public static boolean equals(Throwable t1, Throwable t2) {
LOGGER.fine(() -> "Same object: " + t1);
return true;
}
String id1 = findId(t1, new HashSet<>());
if (id1 != null) {
String id2 = findId(t2, new HashSet<>());
if (id1.equals(id2)) {
LOGGER.fine(() -> "ErrorId matches: " + id1);
return true;
}
LOGGER.fine(() -> "ErrorId mismatch: " + t1 + " " + id1 + " vs. " + t2 + " " + id2);
} else {
LOGGER.fine(() -> "No ErrorId on " + t1);
}
if (t1.getClass() != t2.getClass()) {
boolean noProxy = t1.getClass() != ProxyException.class && t2.getClass() != ProxyException.class;
if (noProxy && t1.getClass() != t2.getClass()) {

Check warning on line 189 in src/main/java/org/jenkinsci/plugins/workflow/actions/ErrorAction.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 189 is only partially covered, one branch is missing
LOGGER.fine(() -> "Different types: " + t1.getClass() + " vs. " + t2.getClass());

Check warning on line 190 in src/main/java/org/jenkinsci/plugins/workflow/actions/ErrorAction.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 190 is not covered by tests
return false;
} else if (!Objects.equals(t1.getMessage(), t2.getMessage())) {
} else if (noProxy && !Objects.equals(t1.getMessage(), t2.getMessage())) {
LOGGER.fine(() -> "Different messages: " + t1.getMessage() + " vs. " + t2.getMessage());
return false;
} else {
String id1 = findId(t1, new HashSet<>());
if (id1 != null) {
String id2 = findId(t2, new HashSet<>());
if (id1.equals(id2)) {
LOGGER.fine(() -> "ErrorId matches: " + id1);
return true;
} else {
LOGGER.fine(() -> "ErrorId mismatch: " + t1 + " " + id1 + " vs. " + t2 + " " + id2);
return false;
}
}
// No ErrorId, use a best-effort approach that doesn't work across restarts for exceptions thrown
// synchronously from the CPS VM thread.
// Check that stack traces match, but specifically avoid checking suppressed exceptions, which are often
Expand Down

0 comments on commit fd98329

Please sign in to comment.