-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Javanica: HystrixCommandAspect not able to get generic class type #784
Comments
@dmgcodevil Any thoughts on this one? |
Not so far but I'll check it.
|
@vibhaanshu you have this problem because you use JDK proxy in spring. Actually if you have interface for bean then spring automatically creates proxy using JDK, otherwise cglib. Proxy created using jdk doesn't have information about annotations. You should use cglib proxies instead of jdk.
|
Thanks |
@vibhaanshu hold on. I was convinced that javanica works fine with jdk proxy and I'm sure that I did some work to have it works. ProceedingJoinPoint has two methods: getThis() returns proxy, but getTarget() returns real object and we can get real type. So jdk proxies shouldn't be a problem but it is not true and let me explain why .I spent couple hours to figure out. I found the root cause of the issue. Java creates bridge methods for methods with generics (I forgot about that...): public static Class[] getParameterTypes(JoinPoint joinPoint) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
return method.getParameterTypes();
} this code returns paramter types for bridge method and results to array with raw types, i.e. array Objects. |
I'm using hystrix command on a class which is implementing generic interface. HystrixCommandAspect is not able to retrieve the parameter types of the child class.
Inside
HystrixCommandAspect
Method value is coming aspublic java.lang.String HelloComponent.getValue(java.lang.Object,java.lang.Object)
. Because of this it throws errorhystrixCommand cannot be null
.The text was updated successfully, but these errors were encountered: