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

Javanica fallback not found when contained in super class #1177

Closed
ctoestreich opened this issue Apr 13, 2016 · 8 comments
Closed

Javanica fallback not found when contained in super class #1177

ctoestreich opened this issue Apr 13, 2016 · 8 comments

Comments

@ctoestreich
Copy link

We are using the Annotated methods on classes where a service extends another service

class WishlistService extends CartService { ... }

And then inside CartService there is a some methods like

 @HystrixCommand(commandProperties = [
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "5000")
    ], threadPoolProperties = [
            @HystrixProperty(name = "coreSize", value = "20"),
            @HystrixProperty(name = "maxQueueSize", value = "150"),
            @HystrixProperty(name = "queueSizeRejectionThreshold", value = "150")
    ], threadPoolKey = 'CartService', fallbackMethod = 'transferItemsFallback')
    CartResponseDTO transferItems(CartKey fromKey, CartKey toKey, List itemIds){
     ...
}

CartResponseDTO transferItemsFallback(CartKey fromKey, CartKey toKey, List items, Throwable e) { ... }

When using the service wishListService in a class the following exception is thrown

com.netflix.hystrix.contrib.javanica.exception.FallbackDefinitionException: fallback method wasn't found: transferItemsFallback([class com.bsb.cart.domain.CartKey, class com.bsb.cart.domain.CartKey, interface java.util.List])
    at com.netflix.hystrix.contrib.javanica.utils.MethodProvider.getFallbackMethod(MethodProvider.java:82) ~[hystrix-javanica-1.5.2.jar:1.5.2]
    at com.netflix.hystrix.contrib.javanica.utils.MethodProvider.getFallbackMethod(MethodProvider.java:55) ~[hystrix-javanica-1.5.2.jar:1.5.2]
    at com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect$MetaHolderFactory.metaHolderBuilder(HystrixCommandAspect.java:120) ~[hystrix-javanica-1.5.2.jar:1.5.2]
    at com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect$CommandMetaHolderFactory.create(HystrixCommandAspect.java:208) ~[hystrix-javanica-1.5.2.jar:1.5.2]
    at com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect$MetaHolderFactory.create(HystrixCommandAspect.java:106) ~[hystrix-javanica-1.5.2.jar:1.5.2]

It would appear that when calling reflection for the class in com.netflix.hystrix.contrib.javinca.utils.MethodProvider line 92
return Optional.of(type.getDeclaredMethod(name, parameterTypes)); it does not resolve the super classes fallback method.

We are using groovy and grails and this may be a factor in the evaluation of the type methods via reflection. However calling the following DOES resolve the method.

type.getSuperclass().getDeclaredMethod(name, parameterTypes)

screen shot 2016-04-13 at 10 27 47 am

@mattrjacobs
Copy link
Contributor

@dmgcodevil Any thoughts on this one?

@mattrjacobs mattrjacobs changed the title Javinca fallback not found when contained in super class Javanica fallback not found when contained in super class Apr 18, 2016
@dmgcodevil
Copy link
Contributor

Interesting, will take a look. Ok.
On 18 Apr 2016 7:04 p.m., "Matt Jacobs" notifications@github.com wrote:

@dmgcodevil https://github.com/dmgcodevil Any thoughts on this one?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#1177 (comment)

@bischoje
Copy link

bischoje commented Jun 17, 2016

We have the exact same scenario and problem as ctoestreich describes in this issue. However, we are not using Groovy or Grails, just plain Java.

I'm going to attempt a workaround for this in my project by declaring the fallback methods as 'abstract' in the super class (which happens to be abstract in my project), thus forcing the subclasses to implement them. This workaround obviously won't work for everyone, so it would be good to make the fallback method search more robust so it can find inherited methods too!

@mattrjacobs
Copy link
Contributor

ping @dmgcodevil

any thoughts?

@dmgcodevil
Copy link
Contributor

Hi was busy with other activities, on the next weekend I will recall all
existing issues and try fix them at once. Sorry for inconvenience.
On 20 Jun 2016 11:26 p.m., "Matt Jacobs" notifications@github.com wrote:

ping @dmgcodevil https://github.com/dmgcodevil

any thoughts?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1177 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABWS8SyhP5kQvQpZltDqiQ9ddemEg3fGks5qN1nMgaJpZM4IGg2z
.

@bischoje
Copy link

My workaround to implement in the subclasses is working for now. It would be great to resolve this though, thank you in advance!

@dmgcodevil
Copy link
Contributor

@mattrjacobs can we close ?

@mattrjacobs
Copy link
Contributor

Yes, thanks @dmgcodevil !

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

No branches or pull requests

4 participants