File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
rxjava-core/src/main/java/rx/operators Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 24
24
import rx .Observable .OnSubscribeFunc ;
25
25
import rx .Observer ;
26
26
import rx .Subscription ;
27
+ import rx .subscriptions .CompositeSubscription ;
27
28
import rx .util .CompositeException ;
28
29
29
30
/**
@@ -151,13 +152,26 @@ private MergeDelayErrorObservable(Observable<? extends Observable<? extends T>>
151
152
}
152
153
153
154
public Subscription onSubscribe (Observer <? super T > actualObserver ) {
155
+ CompositeSubscription completeSubscription = new CompositeSubscription ();
156
+
157
+ /**
158
+ * We must synchronize a merge because we subscribe to multiple sequences in parallel that will each be emitting.
159
+ * <p>
160
+ * The calls from each sequence must be serialized.
161
+ * <p>
162
+ * Bug report: https://github.com/Netflix/RxJava/issues/614
163
+ */
164
+ SafeObservableSubscription subscription = new SafeObservableSubscription (ourSubscription );
165
+ completeSubscription .add (subscription );
166
+ SynchronizedObserver <T > synchronizedObserver = new SynchronizedObserver <T >(actualObserver , subscription );
167
+
154
168
/**
155
169
* Subscribe to the parent Observable to get to the children Observables
156
170
*/
157
- sequences .subscribe (new ParentObserver (actualObserver ));
171
+ completeSubscription . add ( sequences .subscribe (new ParentObserver (actualObserver ) ));
158
172
159
173
/* return our subscription to allow unsubscribing */
160
- return ourSubscription ;
174
+ return completeSubscription ;
161
175
}
162
176
163
177
/**
You can’t perform that action at this time.
0 commit comments