File tree Expand file tree Collapse file tree 3 files changed +35
-3
lines changed
main/java/rx/internal/operators
test/java/rx/internal/operators Expand file tree Collapse file tree 3 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,14 @@ public void call() {
63
63
}
64
64
}));
65
65
}
66
-
66
+
67
+ @ Override
68
+ public void onStart () {
69
+ // no need for more than 1 at a time since we concat 1 at a time, so we'll request 2 to start ...
70
+ // 1 to be subscribed to, 1 in the queue, then we'll keep requesting 1 at a time after that
71
+ request (2 );
72
+ }
73
+
67
74
@ Override
68
75
public void onNext (Observable <? extends T > t ) {
69
76
queue .add (nl .next (t ));
@@ -85,22 +92,25 @@ public void onCompleted() {
85
92
subscribeNext ();
86
93
}
87
94
}
95
+
88
96
void completeInner () {
97
+ request (1 );
89
98
if (WIP_UPDATER .decrementAndGet (this ) > 0 ) {
90
99
subscribeNext ();
91
100
}
92
101
}
102
+
93
103
void subscribeNext () {
94
104
Object o = queue .poll ();
95
105
if (nl .isCompleted (o )) {
96
106
s .onCompleted ();
97
- } else
98
- if (o != null ) {
107
+ } else if (o != null ) {
99
108
Observable <? extends T > obs = nl .getValue (o );
100
109
Subscriber <T > sourceSub = new Subscriber <T >() {
101
110
102
111
@ Override
103
112
public void onNext (T t ) {
113
+ // TODO need to support backpressure here https://github.com/Netflix/RxJava/issues/1480
104
114
s .onNext (t );
105
115
}
106
116
Original file line number Diff line number Diff line change @@ -63,6 +63,12 @@ public ExactSubscriber(Subscriber<? super Observable<T>> child) {
63
63
this .child = child ;
64
64
}
65
65
66
+ @ Override
67
+ public void onStart () {
68
+ // no backpressure as we are controlling data flow by window size
69
+ request (Long .MAX_VALUE );
70
+ }
71
+
66
72
@ Override
67
73
public void onNext (T t ) {
68
74
if (count ++ % size == 0 ) {
@@ -106,6 +112,12 @@ public InexactSubscriber(Subscriber<? super Observable<T>> child) {
106
112
this .chunks = new LinkedList <CountedSubject <T >>();
107
113
}
108
114
115
+ @ Override
116
+ public void onStart () {
117
+ // no backpressure as we are controlling data flow by window size
118
+ request (Long .MAX_VALUE );
119
+ }
120
+
109
121
@ Override
110
122
public void onNext (T t ) {
111
123
if (count ++ % skip == 0 ) {
Original file line number Diff line number Diff line change 15
15
*/
16
16
package rx .internal .operators ;
17
17
18
+ import static org .junit .Assert .assertEquals ;
18
19
import static org .junit .Assert .fail ;
19
20
import static org .mockito .Matchers .any ;
20
21
import static org .mockito .Matchers .anyString ;
@@ -650,4 +651,13 @@ public void call(Subscriber<? super Observable<Integer>> s) {
650
651
inOrder .verify (o ).onCompleted ();
651
652
verify (o , never ()).onError (any (Throwable .class ));
652
653
}
654
+
655
+ @ Test
656
+ public void testConcatOuterBackpressure () {
657
+ assertEquals (1 ,
658
+ (int ) Observable .<Integer > empty ()
659
+ .concatWith (Observable .just (1 ))
660
+ .take (1 )
661
+ .toBlocking ().single ());
662
+ }
653
663
}
You can’t perform that action at this time.
0 commit comments