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

Demonstrate how to tell if a user-supplied getFallback() exists #529

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.netflix.hystrix;

import java.lang.ref.Reference;
import java.util.Arrays;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -307,11 +308,19 @@ public void call(Subscriber<? super R> s) {

@Override
final protected Observable<R> getFallbackObservable() {
final HystrixCommand<R> _self = this;

return Observable.create(new OnSubscribe<R>() {

@Override
public void call(Subscriber<? super R> s) {
try {
try {
_self.getClass().getDeclaredMethod("getFallback");
System.out.println("Fallback *WAS* FOUND!");
} catch (NoSuchMethodException nmse) {
System.out.println("Fallback not found!");
}
s.onNext(getFallback());
s.onCompleted();
} catch (Throwable e) {
Expand Down