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

Added unit test that demonstrates calling .retry() on an Observable produced by Hystrix does not result in deadlock #1406

Merged
merged 1 commit into from
Oct 27, 2016
Merged
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 @@ -29,6 +29,7 @@
import com.netflix.hystrix.strategy.concurrency.HystrixRequestContext;
import com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook;
import com.netflix.hystrix.strategy.properties.HystrixProperty;
import com.sun.javafx.collections.NonIterableChange;
import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -3940,6 +3941,43 @@ public void onNext(String s) {
System.out.println("ReqLog : " + HystrixRequestLog.getCurrentRequest().getExecutedCommandsAsString());
}

@Test
public void testRxRetry() throws Exception {
// see https://github.com/Netflix/Hystrix/issues/1100
// Since each command instance is single-use, the expectation is that applying the .retry() operator
// results in only a single execution and propagation out of that error
HystrixCommand<Integer> cmd = getLatentCommand(ExecutionIsolationStrategy.THREAD, AbstractTestHystrixCommand.ExecutionResult.FAILURE, 300,
AbstractTestHystrixCommand.FallbackResult.UNIMPLEMENTED, 100);

final CountDownLatch latch = new CountDownLatch(1);

System.out.println(System.currentTimeMillis() + " : Starting");
Observable<Integer> o = cmd.toObservable().retry(2);
System.out.println(System.currentTimeMillis() + " Created retried command : " + o);

o.subscribe(new Subscriber<Integer>() {
@Override
public void onCompleted() {
System.out.println(System.currentTimeMillis() + " : " + Thread.currentThread().getName() + " : OnCompleted");
latch.countDown();
}

@Override
public void onError(Throwable e) {
System.out.println(System.currentTimeMillis() + " : " + Thread.currentThread().getName() + " : OnError : " + e);
latch.countDown();
}

@Override
public void onNext(Integer integer) {
System.out.println(System.currentTimeMillis() + " : " + Thread.currentThread().getName() + " : OnNext : " + integer);
}
});

latch.await(1000, TimeUnit.MILLISECONDS);
System.out.println(System.currentTimeMillis() + " ReqLog : " + HystrixRequestLog.getCurrentRequest().getExecutedCommandsAsString());
}

/**
*********************** THREAD-ISOLATED Execution Hook Tests **************************************
*/
Expand Down