Netflix / Hystrix

Hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.
24.08k stars 4.7k forks source link

HystrixCommandAspect doesn't work on proxied classes #1941

Open novy1234 opened 5 years ago

novy1234 commented 5 years ago

Hi. I found issue in HystrixCommandAspect when it is executed on dynamically proxied class. Namely in method methodsAnnotatedWithHystrixCommand there is method retrieval from joinPoint. It uses AopUtils which executes following line

getDeclaredMethod(joinPoint.getTarget().getClass(), signature.getName(),
                    getParameterTypes(joinPoint))

The problem is with joinPoint.getTarget() because it points to proxy class which doesn't have annotations. The result is nice method reference which doesn't have any annotations on it, including @HystrixCommand. Because of this it fails below on extracting MetaHolderFactory from map.

Perhaps changing this line to following one might solve the issue

getDeclaredMethod(signature.getDeclaringType(), signature.getName(),
                    getParameterTypes(joinPoint))

Version: spring-cloud-starter-netflix-hystrix v2.0.2 hystrix-javanica 1.5.12