Skip to content

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

@vietj

Description

@vietj

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());
  }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions