Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About RecoverAnnotationRecoveryHandler's recover method #186

Open
angelsinistanbul opened this issue Oct 31, 2019 · 1 comment
Open

About RecoverAnnotationRecoveryHandler's recover method #186

angelsinistanbul opened this issue Oct 31, 2019 · 1 comment

Comments

@angelsinistanbul
Copy link

angelsinistanbul commented Oct 31, 2019

Hello,

If you use more than exceptions to catch it by divided recover methods , you should change the method. Because, i have debugged the code, the "recover" method's cause always gives us "Throwable.class". Thus, I changed the code by using commons lib,

Throwable rootCause = ExceptionUtils.getRootCause(cause);

to get cause..

You should change the code by doing this if you want.

 public T recover(Object[] args, Throwable cause) {
        Method method = findClosestMatch(args, ExceptionUtils.getRootCause(cause).getClass());
        if (method == null) {
            throw new ExhaustedRetryException("Cannot locate recovery method", cause);
        }
        SimpleMetadata meta = (SimpleMetadata) this.methods.get(method);
        Object[] argsToUse = meta.getArgs(cause, args);
        boolean methodAccessible = method.isAccessible();
        try {
            ReflectionUtils.makeAccessible(method);

            T result = (T) ReflectionUtils.invokeMethod(method, this.target, argsToUse);
            return result;
        } finally {

            if (methodAccessible != method.isAccessible()) {
                method.setAccessible(methodAccessible);
            }
        }
    }
@dsyer
Copy link
Member

dsyer commented Jan 20, 2020

Sorry, I'm not sure what code you are talking about. Would you like to propose a change in a pull request? Or be a bit more specific about where the snippets above come from or apply to?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants