Source:
<code>private void runHealthcheck() { Optional<HealthcheckOptions> maybeOptions = task.getTaskDefinition().getHealthcheckOptions(); Optional<String> expectedHealthcheckResultFilePath = task.getTaskDefinition().getHealthcheckResultFilePath(); <START> String taskAppDirectory = task.getTaskDefinition().getTaskAppDirectory(); <END> if (maybeOptions.isPresent() && expectedHealthcheckResultFilePath.isPresent()) { LOG.debug("Checking for healthcheck file {}", expectedHealthcheckResultFilePath.get()); File fullHealthcheckPath = Paths.get(taskAppDirectory, expectedHealthcheckResultFilePath.get()).toFile(); try { Integer healthcheckMaxRetries = maybeOptions.get().getMaxRetries().or(configuration.getDefaultHealthcheckMaxRetries()); Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder() .retryIfResult(bool -> !bool) .withWaitStrategy(WaitStrategies.fixedWait(1L, TimeUnit.SECONDS)) .withStopStrategy(StopStrategies.stopAfterAttempt(healthcheckMaxRetries)) .build(); retryer.call(() -> fullHealthcheckPath.exists()); executorUtils.sendStatusUpdate(task.getDriver(), task.getTaskInfo().getTaskId(), Protos.TaskState.TASK_RUNNING, String.format("Task running process %s (health check file found successfully).", getCurrentProcessToString()), task.getLog()); } catch (ExecutionException | RetryException e) { executorUtils.sendStatusUpdate(task.getDriver(), task.getTaskInfo().getTaskId(), TaskState.TASK_FAILED, String.format("Task timed out on health checks (health check file not found)."), task.getLog()); } } else { executorUtils.sendStatusUpdate(task.getDriver(), task.getTaskInfo().getTaskId(), Protos.TaskState.TASK_RUNNING, String.format("Task running process %s", getCurrentProcessToString()), task.getLog()); } }</code><technical_language>nit, this needs if statement</technical_language>

Target:
private void runHealthcheck() { Optional<HealthcheckOptions> maybeOptions = task.getTaskDefinition().getHealthcheckOptions(); Optional<String> expectedHealthcheckResultFilePath = task.getTaskDefinition().getHealthcheckResultFilePath(); if (maybeOptions.isPresent() && expectedHealthcheckResultFilePath.isPresent()) { LOG.debug("Checking for healthcheck file {}", expectedHealthcheckResultFilePath.get()); String taskAppDirectory = task.getTaskDefinition().getTaskAppDirectory(); File fullHealthcheckPath = Paths.get(taskAppDirectory, expectedHealthcheckResultFilePath.get()).toFile(); try { Integer healthcheckMaxRetries = maybeOptions.get().getMaxRetries().or(configuration.getDefaultHealthcheckMaxRetries()); Integer retryInterval = maybeOptions.get().getIntervalSeconds().or(5); Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder() .retryIfResult(bool -> !bool) .withWaitStrategy(WaitStrategies.fixedWait(retryInterval, TimeUnit.SECONDS)) .withStopStrategy(StopStrategies.stopAfterAttempt(healthcheckMaxRetries)) .build(); retryer.call(() -> fullHealthcheckPath.exists()); executorUtils.sendStatusUpdate(task.getDriver(), task.getTaskInfo().getTaskId(), Protos.TaskState.TASK_RUNNING, String.format("Task running process %s (health check file found successfully).", getCurrentProcessToString()), task.getLog()); } catch (ExecutionException | RetryException e) { executorUtils.sendStatusUpdate(task.getDriver(), task.getTaskInfo().getTaskId(), TaskState.TASK_FAILED, String.format("Task timed out on health checks (health check file not found)."), task.getLog()); } } else { executorUtils.sendStatusUpdate(task.getDriver(), task.getTaskInfo().getTaskId(), Protos.TaskState.TASK_RUNNING, String.format("Task running process %s", getCurrentProcessToString()), task.getLog()); } }