@@ -473,17 +473,7 @@ public void required_spec317_mustSupportAPendingElementCountUpToLongMaxValue_sho
473
473
}
474
474
475
475
@ Test
476
- public void required_spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue_shouldFail_onAsynchDemandIgnoringPublisher () throws Throwable {
477
- final ExecutorService signallersPool = Executors .newFixedThreadPool (2 );
478
- requireTestFailure (new ThrowingRunnable () {
479
- @ Override public void run () throws Throwable {
480
- demandIgnoringAsynchronousPublisherVerification (signallersPool ).required_spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue ();
481
- }
482
- }, "Expected onError(java.lang.IllegalStateException)" );
483
- }
484
-
485
- @ Test
486
- public void required_spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue_shouldFail_onSynchDemandIgnoringPublisher () throws Throwable {
476
+ public void required_spec317_mustNotSignalOnErrorWhenPendingAboveLongMaxValue_shouldFail_onSynchOverflowingPublisher () throws Throwable {
487
477
requireTestFailure (new ThrowingRunnable () {
488
478
@ Override public void run () throws Throwable {
489
479
customPublisherVerification (new Publisher <Integer >() {
@@ -494,20 +484,26 @@ public void required_spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue_shoul
494
484
@ Override public void request (long n ) {
495
485
// it does not protect from demand overflow!
496
486
demand += n ;
487
+ if (demand < 0 ) {
488
+ // overflow
489
+ s .onError (new IllegalStateException ("Illegally signalling onError (violates rule 3.17)" )); // Illegally signal error
490
+ } else {
491
+ s .onNext (0 );
492
+ }
497
493
}
498
494
499
495
@ Override public void cancel () {
500
496
// noop
501
497
}
502
498
});
503
499
}
504
- }).required_spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue ();
500
+ }).required_spec317_mustNotSignalOnErrorWhenPendingAboveLongMaxValue ();
505
501
}
506
- }, "Expected onError(java.lang.IllegalStateException )" );
502
+ }, "Async error during test execution: Illegally signalling onError (violates rule 3.17 )" );
507
503
}
508
504
509
505
@ Test
510
- public void required_spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue_shouldFail_overflowingDemand () throws Throwable {
506
+ public void required_spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue_shouldFailWhenErrorSignalledOnceMaxValueReached () throws Throwable {
511
507
requireTestFailure (new ThrowingRunnable () {
512
508
@ Override public void run () throws Throwable {
513
509
customPublisherVerification (new Publisher <Integer >() {
@@ -520,15 +516,16 @@ public void required_spec317_mustSupportACumulativePendingElementCountUpToLongMa
520
516
521
517
// this is a mistake, it should still be able to accumulate such demand
522
518
if (demand == Long .MAX_VALUE )
523
- s .onError (new IllegalStateException ("I'm signalling onError too soon! Cumulative demand equal to Long.MAX_VALUE is OK by the spec." ));
519
+ s .onError (new IllegalStateException ("Illegally signalling onError too soon! " +
520
+ "Cumulative demand equal to Long.MAX_VALUE is legal." ));
524
521
525
522
s .onNext (0 );
526
523
}
527
524
});
528
525
}
529
526
}).required_spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue ();
530
527
}
531
- }, "Async error during test execution: I'm signalling onError too soon!" );
528
+ }, "Async error during test execution: Illegally signalling onError too soon!" );
532
529
}
533
530
534
531
0 commit comments