Avoid mangling semantics for no reason
@@ -287,9 +287,9 @@ public class DeploymentTrigger {
if (change.isPresent())
for (Step step : productionStepsOf(application)) {
Set<JobType> stepJobs = step.zones().stream().map(order::toJob).collect(toSet());
- Map<Instant, List<JobType>> jobsByCompletion = stepJobs.stream().collect(groupingBy(job -> completedAt(change, application, job).orElse(Instant.MAX)));
- if (jobsByCompletion.containsKey(Instant.MAX)) { // Step incomplete because some jobs remain, trigger those if the previous step was done, or required test steps.
- for (JobType job : jobsByCompletion.get(Instant.MAX)) {
+ Map<Optional<Instant>, List<JobType>> jobsByCompletion = stepJobs.stream().collect(groupingBy(job -> completedAt(change, application, job)));
+ if (jobsByCompletion.containsKey(Optional.empty())) { // Step incomplete because some jobs remain, trigger those if the previous step was done, or required test steps.
+ for (JobType job : jobsByCompletion.get(Optional.empty())) {
Versions versions = versions(application, change, deploymentFor(application, job));
if (isTested(application, versions)) {
if ( completedAt.isPresent()
@@ -313,7 +313,7 @@ public class DeploymentTrigger {
reason += " after a delay of " + delay;
}
else {
- completedAt = jobsByCompletion.keySet().stream().max(naturalOrder());
+ completedAt = jobsByCompletion.keySet().stream().map(Optional::get).max(naturalOrder());
reason = "Available change in " + stepJobs.stream().map(JobType::jobName).collect(joining(", "));
}
}
