Browse Source

Housekeeper: cancel task future in finally block

pull/12163/head
ViacheslavKlimov 2 years ago
parent
commit
dd02e44822
  1. 5
      application/src/main/java/org/thingsboard/server/service/housekeeper/HousekeeperService.java

5
application/src/main/java/org/thingsboard/server/service/housekeeper/HousekeeperService.java

@ -138,7 +138,6 @@ public class HousekeeperService {
if (e instanceof ExecutionException) {
error = e.getCause();
} else if (e instanceof TimeoutException) {
future.cancel(true); // interrupting the task
error = new TimeoutException("Timeout after " + config.getTaskProcessingTimeout() + " ms");
}
@ -155,6 +154,10 @@ public class HousekeeperService {
.build());
}
statsService.ifPresent(statsService -> statsService.reportFailure(taskType, msg));
} finally {
if (future != null && !future.isDone()) {
future.cancel(true);
}
}
}

Loading…
Cancel
Save