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

Observable#concat(Observable,Observable) subscribed with an Observer has Disposable#isDisposed false after completion #5439

Closed
vietj opened this issue Jun 25, 2017 · 5 comments

Comments

@vietj
Copy link

vietj commented Jun 25, 2017

Thanks for using RxJava but before you post an issue, please consider the following points:

  • Please include the library version number, including the minor and patch version, in the issue text. In addition, if you'd include the major version in the title (such as 2.x) that would be great.

2.1.1

  • If you think you found a bug, please include a code sample that reproduces the problem. Dumping a stacktrace is usually not enough for us.
  // Fail
  @Test
  public void testConcatWithObserver() {
    Observable<String> s = Observable.concat(Observable.just("abc"), Observable.just("def"));
    AtomicReference<Disposable> disposable = new AtomicReference<>();
    LinkedList<String> list = new LinkedList<>();
    AtomicBoolean completed = new AtomicBoolean();
    s.subscribe(new Observer<String>() {
      public void onSubscribe(Disposable d) { disposable.set(d); }
      public void onNext(String s) { list.add(s); }
      public void onError(Throwable e) {}
      public void onComplete() { completed.set(true); }
    });
    assertTrue(completed.get());
    assertEquals(Arrays.asList("abc", "def"), list);
    assertTrue(disposable.get().isDisposed());
  }

  // Pass
  @Test
  public void testConcatWithActions() {
    Observable<String> s = Observable.concat(Observable.just("abc"), Observable.just("def"));
    AtomicReference<Disposable> disposable = new AtomicReference<>();
    LinkedList<String> list = new LinkedList<>();
    AtomicBoolean completed = new AtomicBoolean();
    s.subscribe(list::add, err -> {}, () -> completed.set(true), disposable::set);
    assertTrue(completed.get());
    assertEquals(Arrays.asList("abc", "def"), list);
    assertTrue(disposable.get().isDisposed());
  }
@akarnokd akarnokd added the 2.x label Jun 25, 2017
@akarnokd
Copy link
Member

Why do you want to rely on isDisposed externally to a sequence?

@vietj
Copy link
Author

vietj commented Jun 25, 2017

it is for testing isDisposed in the RxJava2 / Vert.x integration

@akarnokd
Copy link
Member

You could call disposable.set(Disposables.disposed()) in onError and onComplete or otherwise simply rely on complete.get().

@vietj
Copy link
Author

vietj commented Jun 26, 2017

I don't understand what you mean.

I am merely reporting a difference of behavior where disposable.get().isDisposed() returns false for testConcatWithObserver and it seems to me that it should return true with this above reproducer.

If I replace the Observable.concat(...) by Observable.just("foo"), then disposable.get().isDisposed() will be true in both cases.

@akarnokd
Copy link
Member

akarnokd commented Jul 5, 2017

Closing via #5440.

@akarnokd akarnokd closed this as completed Jul 5, 2017
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

2 participants