diff --git a/rxjava-core/src/main/java/rx/operators/OperationMaterialize.java b/rxjava-core/src/main/java/rx/operators/OperationMaterialize.java index 1e22154e146..279bff006a2 100644 --- a/rxjava-core/src/main/java/rx/operators/OperationMaterialize.java +++ b/rxjava-core/src/main/java/rx/operators/OperationMaterialize.java @@ -19,6 +19,7 @@ import java.util.List; import java.util.Vector; +import java.util.concurrent.ExecutionException; import org.junit.Test; @@ -139,25 +140,13 @@ public void testMaterialize2() { } @Test - public void testMultipleSubscribes() { - final TestAsyncErrorObservable o1 = new TestAsyncErrorObservable("one", "two", null, "three"); - - Observable> m = Observable.create(materialize(o1)); - - TestObserver Observer1 = new TestObserver(); - m.subscribe(Observer1); - - TestObserver Observer2 = new TestObserver(); - m.subscribe(Observer2); + public void testMultipleSubscribes() throws InterruptedException, ExecutionException { + final TestAsyncErrorObservable o = new TestAsyncErrorObservable("one", "two", null, "three"); - try { - o1.t.join(); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } + Observable> m = Observable.create(materialize(o)); - assertEquals(3, Observer1.notifications.size()); - assertEquals(3, Observer2.notifications.size()); + assertEquals(3, m.toList().toBlockingObservable().toFuture().get().size()); + assertEquals(3, m.toList().toBlockingObservable().toFuture().get().size()); } } @@ -193,7 +182,7 @@ private static class TestAsyncErrorObservable extends Observable { valuesToReturn = values; } - Thread t; + volatile Thread t; @Override public Subscription subscribe(final Observer observer) {