Skip to content

Commit

Permalink
fix: increase revision
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikhorn93 committed Nov 30, 2023
1 parent 448f733 commit 71e4151
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void execute(final WorkerExecutor executor, final ExternalTask externalTa
} catch (final Exception error) {
int retries = getRemainingRetries(externalTask.getRetries(), workerRetries);
log.severe("Error while executing external task " + error.getMessage());
service.handleFailure(externalTask, error.getMessage(), Arrays.toString(error.getStackTrace()), retries -1, 5000L);
service.handleFailure(externalTask, error.getMessage(), Arrays.toString(error.getStackTrace()), retries, 5000L);
}
}

Expand All @@ -66,11 +66,15 @@ public void execute(final WorkerExecutor executor, final ExternalTask externalTa
* @return The remaining number of retries for the task.
*/
private int getRemainingRetries(Integer externalTaskRetries, Integer workerRetries) {
int retries = 0;
if (Objects.isNull(externalTaskRetries)) {
return Objects.isNull(workerRetries) ?
retries = Objects.isNull(workerRetries) ?
camunda7WorkerProperties.getDefaultRetries() :
workerRetries;
}else {
retries = externalTaskRetries;
}
return externalTaskRetries;
retries -= 1;
return Math.max(retries, 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void givenDefaultUseCaseAndRetriesProvided_thenInvokeGetRemainingRetries() throw

var retriesCaptor = ArgumentCaptor.forClass(Integer.class);
then(service).should().handleFailure((ExternalTask) any(), any(), any(), retriesCaptor.capture(), anyLong());
assertEquals(3, retriesCaptor.getValue());
assertEquals(3-1, retriesCaptor.getValue());
}

@Test
Expand All @@ -101,7 +101,7 @@ void givenDefaultUseCaseAndRetriesSetInBpmn_thenUseBpmnRetries() {

adapter.execute(defaultWorker, externalTask, service);

then(service).should().handleFailure((ExternalTask) any(), any(), any(), eq(bpmnRetries), anyLong());
then(service).should().handleFailure((ExternalTask) any(), any(), any(), eq(bpmnRetries-1), anyLong());
}

@Test
Expand All @@ -117,7 +117,7 @@ void givenDefaultUseCaseAndRetriesSetInWorkerInput_thenUseWorkerRetries() {

adapter.execute(defaultWorker, externalTask, service);

then(service).should().handleFailure((ExternalTask) any(), any(), any(), eq(workerRetries), anyLong());
then(service).should().handleFailure((ExternalTask) any(), any(), any(), eq(workerRetries-1), anyLong());
}

@Test
Expand All @@ -131,7 +131,7 @@ void givenDefaultUseCaseAndNoRetriesProvided_thenUseDefaultRetries() {

adapter.execute(defaultWorker, externalTask, service);

then(service).should().handleFailure((ExternalTask) any(), any(), any(), eq(defaultRetries), anyLong());
then(service).should().handleFailure((ExternalTask) any(), any(), any(), eq(defaultRetries-1), anyLong());
}

@Test
Expand Down

0 comments on commit 71e4151

Please sign in to comment.