-
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
Bug: Premature Unsubscribe #295
Comments
I don't experience a hang when I run this code. Are you saying you don't see 3 lines print?
|
I only see 2 lines print and the JVM is still running
|
I see 3 lines when using Hystrix 1.3.9 and RxJava 0.16.1 |
I haven't tested with 1.3.9. I'm using the latest which is 1.3.16: https://github.com/Netflix/Hystrix/releases/tag/1.3.16 |
When I tried with 1.3.16 it hanged and only outputted 2 lines. I reproduced this on Oracle JDK 1.8u5 on OS X and Oracle JDK 1.8u20 on Ubuntu 12.04. |
I created a test project and ran it on Travis CI with the same results |
Weird. I’ll hunt down what’s going on. I don’t understand how this is not happening for me or the Netflix prod environment. Thanks for providing environment details and a test environment. |
In case it helps.. I couldn't reproduce it later today until I added a Thread.sleep in the DummyCommand. public static class DummyCommand extends HystrixCommand<String> {
public DummyCommand() {
super(HystrixCommandGroupKey.Factory.asKey("DummyGroup"));
}
@Override
protected String run() throws Exception {
Thread.sleep(100);
return "foo";
}
} |
Seems like toObservable() unsubscribes the entire chain somehow. System.out.println(LocalDateTime.now() + " Starting");
new DummyCommand().toObservable()
.doOnEach(n -> System.out.println(LocalDateTime.now() + " Before " + n))
.flatMap(s -> Observable.timer(1, TimeUnit.SECONDS).map(v -> s))
.doOnEach(n -> System.out.println(LocalDateTime.now() + " After " + n))
.doOnUnsubscribe(() -> System.out.println(LocalDateTime.now() + " OnUnsubscribe"))
.subscribe();
Thread.sleep(5000); outputs
where System.out.println(LocalDateTime.now() + " Starting");
new DummyCommand().observe()
.doOnEach(n -> System.out.println(LocalDateTime.now() + " Before " + n))
.flatMap(s -> Observable.timer(1, TimeUnit.SECONDS).map(v -> s))
.doOnEach(n -> System.out.println(LocalDateTime.now() + " After " + n))
.doOnUnsubscribe(() -> System.out.println(LocalDateTime.now() + " OnUnsubscribe"))
.subscribe();
Thread.sleep(5000); outputs
|
Also, this is not reproducible in 1.4.0-RC4. |
Alright ... I can replicate now. Hystrix 1.3.16 with RxJava 0.20.x |
This appears to happen in Hystrix 1.3.16 and RxJava 0.18.2 as well, so it's a latent bug that has been there all along. |
Thanks for the quick fix! I confirmed that it addressed the issue in our actual codebase. |
Thanks for the confirmation. |
Updated: This is a pre-mature unsubscribe issue. It happens even with RxJava 0.18.2 and is an issue with Hystrix use of RxJava, not RxJava itself.
Is Hystrix 1.3.16 compatible with RxJava 0.20.0? If not, please close :)
We were using
toObservable()
and noticed that it would work in simple cases, but would hang if we composed additional operators. Could not reproduce when usingobserve()
.Here's a short snippet that reproduces this:
The text was updated successfully, but these errors were encountered: