diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..fcadb2cf --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text eol=lf diff --git a/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/Scheduler.java b/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/Scheduler.java index 9c8ff9f3..7659f315 100644 --- a/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/Scheduler.java +++ b/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/Scheduler.java @@ -359,31 +359,29 @@ protected void detectDeadExecutions() { LOG.debug("Deleting executions with unresolved tasks."); Map unresolvedTaskToNewestExecution = new HashMap<>(); - schedulerTaskRepository - .getScheduledExecutions( + schedulerTaskRepository.getScheduledExecutions( ScheduledExecutionsFilter.all(), - execution -> unresolvedTaskToNewestExecution.merge( - execution.taskInstance.getTaskName(), - execution.executionTime, - (oldValue, newValue) -> oldValue.isAfter(newValue) ? oldValue : newValue - )); - - taskResolver - .getUnresolved() - .stream() + execution -> + unresolvedTaskToNewestExecution.merge( + execution.taskInstance.getTaskName(), + execution.executionTime, + (oldValue, newValue) -> oldValue.isAfter(newValue) ? oldValue : newValue)); + + taskResolver.getUnresolved().stream() .map(UnresolvedTask::getTaskName) - .filter(taskName -> { - Instant newestExecution = unresolvedTaskToNewestExecution.get(taskName); + .filter( + taskName -> { + Instant newestExecution = unresolvedTaskToNewestExecution.get(taskName); - if (newestExecution == null) { - // probably deleted by other node - return true; - } + if (newestExecution == null) { + // probably deleted by other node + return true; + } - Duration age = Duration.between(newestExecution, clock.now()); + Duration age = Duration.between(newestExecution, clock.now()); - return age.compareTo(deleteUnresolvedAfter) >= 0; - }) + return age.compareTo(deleteUnresolvedAfter) >= 0; + }) .forEach( taskName -> { LOG.warn( diff --git a/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/TaskResolver.java b/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/TaskResolver.java index 9a918890..a87824b0 100644 --- a/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/TaskResolver.java +++ b/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/TaskResolver.java @@ -17,7 +17,6 @@ import com.github.kagkarlsson.scheduler.stats.StatsRegistry; import com.github.kagkarlsson.scheduler.task.Task; -import java.time.Duration; import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; diff --git a/db-scheduler/src/test/java/com/github/kagkarlsson/scheduler/DeadExecutionsTest.java b/db-scheduler/src/test/java/com/github/kagkarlsson/scheduler/DeadExecutionsTest.java index 23c7fa12..f6804439 100644 --- a/db-scheduler/src/test/java/com/github/kagkarlsson/scheduler/DeadExecutionsTest.java +++ b/db-scheduler/src/test/java/com/github/kagkarlsson/scheduler/DeadExecutionsTest.java @@ -118,7 +118,6 @@ public void scheduler_should_detect_dead_execution_that_never_updated_heartbeat( assertThat(nonCompletingExecutionHandler.timesExecuted.get(), is(2)); } - public static class NonCompletingTask extends OneTimeTask { private final VoidExecutionHandler handler;