Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public boolean onFail() throws JobException {
return false;
}
status = TaskStatus.FAILED;
setFinishTimeMs(System.currentTimeMillis());
if (!isCallable()) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ boolean cancelLogicCalled() {
}
}

private static class FailingTask extends DummyTask {
FailingTask(long taskId) {
super(taskId);
setJobId(1L);
}

@Override
public void run() throws JobException {
throw new JobException("task failed");
}
}

private static class DummyJob extends AbstractJob<DummyTask, Void> {
private final List<DummyTask> history = new ArrayList<>();

Expand Down Expand Up @@ -131,6 +143,17 @@ void testPendingFromPaused() throws Exception {
Assertions.assertEquals(JobStatus.PENDING, job.getJobStatus());
}

@Test
void testTaskFailureSetsFinishTime() throws Exception {
FailingTask task = new FailingTask(100L);

task.runTask();

Assertions.assertEquals(TaskStatus.FAILED, task.getStatus());
Assertions.assertNotNull(task.getFinishTimeMs());
Assertions.assertEquals("task failed", task.getErrMsg());
}

@Test
void testPendingFromRunning() throws Exception {
DummyJob job = new DummyJob(JobStatus.RUNNING);
Expand Down
Loading