Skip to content

Commit 1ae4053

Browse files
Merge pull request #926 from benjchristensen/test-subscriber
TestSubscriber: Default onError and Terminal Latch Behavior
2 parents 886caeb + bdfd9fe commit 1ae4053

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

rxjava-core/src/main/java/rx/observers/TestSubscriber.java

+28-5
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,33 @@ public TestSubscriber(Observer<T> delegate) {
4141
}
4242

4343
public TestSubscriber() {
44-
this.testObserver = new TestObserver<T>(Subscribers.<T> empty());
44+
this.testObserver = new TestObserver<T>(new Observer<T>() {
45+
46+
@Override
47+
public void onCompleted() {
48+
// do nothing
49+
}
50+
51+
@Override
52+
public void onError(Throwable e) {
53+
// do nothing
54+
}
55+
56+
@Override
57+
public void onNext(T t) {
58+
// do nothing
59+
}
60+
61+
});
4562
}
4663

4764
@Override
4865
public void onCompleted() {
49-
testObserver.onCompleted();
50-
latch.countDown();
66+
try {
67+
testObserver.onCompleted();
68+
} finally {
69+
latch.countDown();
70+
}
5171
}
5272

5373
public List<Notification<T>> getOnCompletedEvents() {
@@ -56,8 +76,11 @@ public List<Notification<T>> getOnCompletedEvents() {
5676

5777
@Override
5878
public void onError(Throwable e) {
59-
testObserver.onError(e);
60-
latch.countDown();
79+
try {
80+
testObserver.onError(e);
81+
} finally {
82+
latch.countDown();
83+
}
6184
}
6285

6386
public List<Throwable> getOnErrorEvents() {

0 commit comments

Comments
 (0)