Skip to content

IllegalArgumentException when migrating from 1.3.1 to 1.3.2 and using class annotations #299

@deadpassive

Description

@deadpassive

Hi,

I am using a setup similar to the following, where I have a @Retryable defined on the class and also a @Recover method.

@Retryable(value = {MyFirstException.class, MySecondException.class})
@Service
public class MyService {

  public void myMethod(String myArg) {
    System.out.println("Doing a thing that will fail with args " + myArg);
    throw new MyFirstException();
  }

  @Recover
  public void recoverMyMethod(Exception e, String myArg) throws Exception {
    System.out.println("In recovery, with args " + myArg);
    throw e;
  }
}

When running with spring-retry v1.3.1 this worked fine and myMethod is run 3 times before recoverMyMethod is called a single time before the exception is finally thrown.

When running with v1.3.2 or v1.3.3 of spring-retry the behaviour changes and it also retries the recover method too. So myMethod is called 3 times and then recoverMyMethod is called 3 times before finally an IllegalArgumentException is thrown.

I think this exception is thrown because it is trying to call recoverMyMethod to recover from itself and gets confused when creating the args to call it and ends up trying to call it with (Exception, Exception) instead of (Exception, String).

Is this a bug in spring-retry, or are we using it incorrectly?

Here is an example project which illustrates the issue:
spring-retry-test.zip

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions