Skip to content

Commit

Permalink
Defending against past corrupt builds (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlatombe committed Sep 26, 2024
1 parent 2a6bf20 commit ab878c3
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/main/java/hudson/tasks/test/TestResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
*/
package hudson.tasks.test;

import hudson.model.Job;
import hudson.model.Result;
import hudson.model.Run;
import hudson.tasks.junit.TestAction;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* A class that represents a general concept of a test result, without any
Expand All @@ -38,6 +41,7 @@
* @since 1.343
*/
public abstract class TestResult extends TestObject {
private static final Logger LOGGER = Logger.getLogger(TestResult.class.getName());

/**
* If the concept of a parent action is important to a subclass, then it should
Expand Down Expand Up @@ -136,17 +140,27 @@ public TestResult getPreviousResult() {
if (b == null) {
return null;
}
Job<?, ?> job = b.getParent();
while (true) {
b = b.getPreviousBuild();
if (b == null) {
return null;
}
AbstractTestResultAction r = b.getAction(getParentAction().getClass());
if (r != null) {
TestResult result = r.findCorrespondingResult(this.getId());
if (result != null) {
return result;
try {
AbstractTestResultAction r = b.getAction(getParentAction().getClass());
if (r != null) {
TestResult result = r.findCorrespondingResult(this.getId());
if (result != null) {
return result;
}
}
} catch (RuntimeException e) {
Run<?, ?> loggedBuild = b;
LOGGER.log(
Level.WARNING,
e,
() -> "Failed to load (corrupt?) build " + job.getFullName() + " #" + loggedBuild.getNumber()

Check warning on line 162 in src/main/java/hudson/tasks/test/TestResult.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 157-162 are not covered by tests
+ ", skipping");
}
}
}
Expand Down

0 comments on commit ab878c3

Please sign in to comment.