@@ -418,7 +418,7 @@ public void request(long n) {
418
418
}
419
419
return ;
420
420
}
421
- if (n > 0 && req .getAndAdd (1 ) == 0 ) {
421
+ if (n > 0 && req .getAndAdd (n ) == 0 ) {
422
422
int i = count .getAndIncrement ();
423
423
if (i < numFailures ) {
424
424
o .onNext ("beginningEveryTime" );
@@ -722,20 +722,31 @@ public void testRetryWithBackpressureParallel() throws InterruptedException {
722
722
int ncpu = Runtime .getRuntime ().availableProcessors ();
723
723
ExecutorService exec = Executors .newFixedThreadPool (Math .max (ncpu / 2 , 1 ));
724
724
final AtomicInteger timeouts = new AtomicInteger ();
725
- int m = 300 ;
725
+ final AtomicInteger data = new AtomicInteger ();
726
+ int m = 2000 ;
726
727
final CountDownLatch cdl = new CountDownLatch (m );
727
728
for (int i = 0 ; i < m ; i ++) {
728
729
final int j = i ;
729
730
exec .execute (new Runnable () {
730
731
@ Override
731
732
public void run () {
732
733
try {
734
+ final AtomicInteger nexts = new AtomicInteger ();
733
735
Observable <String > origin = Observable .create (new FuncWithErrors (NUM_RETRIES ));
734
736
TestSubscriber <String > ts = new TestSubscriber <String >();
735
737
origin .retry ().observeOn (Schedulers .computation ()).unsafeSubscribe (ts );
736
- if (!ts .awaitTerminalEvent (10 , TimeUnit .SECONDS )) {
738
+ if (!ts .awaitTerminalEvent (2 , TimeUnit .SECONDS )) {
737
739
timeouts .incrementAndGet ();
738
- System .out .println (j + " | " + cdl .getCount () + " !!!" );
740
+ System .out .println (j + " | " + cdl .getCount () + " !!! " + nexts .get ());
741
+ }
742
+ if (ts .getOnNextEvents ().size () != NUM_RETRIES + 2 ) {
743
+ data .incrementAndGet ();
744
+ }
745
+ if (ts .getOnErrorEvents ().size () != 0 ) {
746
+ data .incrementAndGet ();
747
+ }
748
+ if (ts .getOnCompletedEvents ().size () != 1 ) {
749
+ data .incrementAndGet ();
739
750
}
740
751
} catch (Throwable t ) {
741
752
timeouts .incrementAndGet ();
@@ -747,6 +758,7 @@ public void run() {
747
758
exec .shutdown ();
748
759
cdl .await ();
749
760
assertEquals (0 , timeouts .get ());
761
+ assertEquals (0 , data .get ());
750
762
751
763
}
752
764
@ Test (timeout = 3000 )
0 commit comments