1212import com .fasterxml .jackson .databind .ObjectMapper ;
1313import com .fasterxml .jackson .dataformat .yaml .YAMLFactory ;
1414
15+ import org .elasticsearch .gradle .internal .test .rerun .model .FailedTestsReport ;
1516import org .elasticsearch .gradle .internal .test .rerun .model .TestCase ;
1617import org .elasticsearch .gradle .internal .test .rerun .model .WorkUnit ;
1718import org .gradle .api .file .Directory ;
18- import org .gradle .api .model .ObjectFactory ;
1919import org .gradle .api .provider .Provider ;
2020import org .gradle .api .tasks .testing .Test ;
2121import org .gradle .api .tasks .testing .TestDescriptor ;
@@ -33,12 +33,13 @@ public final class TestTaskConfigurer {
3333
3434 private TestTaskConfigurer () {}
3535
36- public static void configureTestTask (
37- Test test ,
38- Provider <RerunPlugin .RetryTestsBuildService > testsBuildServiceProvider ,
39- ObjectFactory objectFactory
40- ) {
41- List <WorkUnit > workUnits = testsBuildServiceProvider .get ().getFailureReport ().getWorkUnits ();
36+ public static void configureTestTask (Test test , Provider <RerunPlugin .RetryTestsBuildService > testsBuildServiceProvider ) {
37+ FailedTestsReport failureReport = testsBuildServiceProvider .get ().getFailureReport ();
38+ if (failureReport == null ) {
39+ // no historical test failures found
40+ return ;
41+ }
42+ List <WorkUnit > workUnits = failureReport .getWorkUnits ();
4243 Optional <WorkUnit > first = workUnits .stream ().filter (workunit -> workunit .getName ().equals (test .getPath ())).findFirst ();
4344 if (first .isPresent ()) {
4445 test .filter (testFilter -> {
0 commit comments