Ожидается повторный метод с аргументом для вызова метода восстановления с аргументом, но на самом деле он вызывает метод без аргумента - PullRequest
0 голосов
/ 05 ноября 2019
@Retryable(maxAttempts = 3, backoff = @Backoff(delay = 1000), value = { Exception.class })
public List<Student> getStudents() throws Exception {
    log.info("retry for three times");
    HttpRequest request = getHttpRequest("/reto/app/meto");
    HttpResponse response = request.execute();
    Policy[] students= response.parseAs(Student[].class);
    return new ArrayList<>(Arrays.asList(students));
}

@Recover
public List<Student> recoverA(Exception ex) {
    log.error("Maximum retries  reached for getStudents");
    return null;
}

@Override
@Retryable(maxAttempts = 3, backoff = @Backoff(delay = 6000), value = { Exception.class })
public List<Employee> getEmployees(long empId) throws Exception {
    log.info("retry for three times.activation.");
    HttpRequest request = getHttpRequest("/cloud/neon/" + empId+ "/activate");
    HttpResponse response = request.execute();
    Activation[] allEmployees= response.parseAs(Employee[].class);
    return new ArrayList<>(Arrays.asList(allEmployees));
}

@Recover
public List<Employee> recoverB(Exception ex,long empId) {
    log.error("Maximum retries  reached for getEmployees");
    return null;
}

Здесь, когда я вызываю метод getEmployees () , он повторяется три раза. После всех успешных попыток он должен вызвать recoverB , но на самом деле он вызывает recoverA . Хотя тип возвращаемого значения и аргументы также одинаковы как для повторяемого метода, так и для метода восстановления.

Однако, если я комментирую метод recoverA , он вызывает требуемый метод recoverB .

...