Skip to content

Commit

Permalink
Fix for Observable.toList failing with multiple subscribers
Browse files Browse the repository at this point in the history
  • Loading branch information
thegeez committed Mar 24, 2013
1 parent 5f77a31 commit c21c1e7
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public static <T> Func1<Observer<List<T>>, Subscription> toObservableList(Observ
private static class ToObservableList<T> implements Func1<Observer<List<T>>, Subscription> {

private final Observable<T> that;
final ConcurrentLinkedQueue<T> list = new ConcurrentLinkedQueue<T>();

public ToObservableList(Observable<T> that) {
this.that = that;
Expand All @@ -49,6 +48,7 @@ public ToObservableList(Observable<T> that) {
public Subscription call(final Observer<List<T>> observer) {

return that.subscribe(new Observer<T>() {
final ConcurrentLinkedQueue<T> list = new ConcurrentLinkedQueue<T>();
public void onNext(T value) {
// onNext can be concurrently executed so list must be thread-safe
list.add(value);
Expand Down

0 comments on commit c21c1e7

Please sign in to comment.