@@ -629,7 +629,7 @@ private class DataLoaderSubscriber implements Subscriber<V> {
629629 private final List <V > completedValues = new ArrayList <>();
630630 private int idx = 0 ;
631631 private boolean onErrorCalled = false ;
632- private boolean onCompletedCalled = false ;
632+ private boolean onCompleteCalled = false ;
633633
634634 private DataLoaderSubscriber (
635635 CompletableFuture <List <V >> valuesFuture ,
@@ -650,7 +650,8 @@ public void onSubscribe(Subscription subscription) {
650650
651651 @ Override
652652 public void onNext (V value ) {
653- assert !onErrorCalled && !onCompletedCalled ;
653+ assertState (!onErrorCalled , () -> "onError has already been called; onNext may not be invoked." );
654+ assertState (!onCompleteCalled , () -> "onComplete has already been called; onNext may not be invoked." );
654655
655656 K key = keys .get (idx );
656657 Object callContext = callContexts .get (idx );
@@ -680,8 +681,8 @@ public void onNext(V value) {
680681
681682 @ Override
682683 public void onComplete () {
683- assert !onErrorCalled ;
684- onCompletedCalled = true ;
684+ assertState ( !onErrorCalled , () -> "onError has already been called; onComplete may not be invoked." ) ;
685+ onCompleteCalled = true ;
685686
686687 assertResultSize (keys , completedValues );
687688
@@ -691,7 +692,7 @@ public void onComplete() {
691692
692693 @ Override
693694 public void onError (Throwable ex ) {
694- assert ! onCompletedCalled ;
695+ assertState (! onCompleteCalled , () -> "onComplete has already been called; onError may not be invoked." ) ;
695696 onErrorCalled = true ;
696697
697698 stats .incrementBatchLoadExceptionCount (new IncrementBatchLoadExceptionCountStatisticsContext <>(keys , callContexts ));
@@ -720,7 +721,7 @@ private class DataLoaderMapEntrySubscriber implements Subscriber<Map.Entry<K, V>
720721 private final List <K > clearCacheKeys = new ArrayList <>();
721722 private final Map <K , V > completedValuesByKey = new HashMap <>();
722723 private boolean onErrorCalled = false ;
723- private boolean onCompletedCalled = false ;
724+ private boolean onCompleteCalled = false ;
724725
725726 private DataLoaderMapEntrySubscriber (
726727 CompletableFuture <List <V >> valuesFuture ,
@@ -751,7 +752,8 @@ public void onSubscribe(Subscription subscription) {
751752
752753 @ Override
753754 public void onNext (Map .Entry <K , V > entry ) {
754- assert !onErrorCalled && !onCompletedCalled ;
755+ assertState (!onErrorCalled , () -> "onError has already been called; onNext may not be invoked." );
756+ assertState (!onCompleteCalled , () -> "onComplete has already been called; onNext may not be invoked." );
755757 K key = entry .getKey ();
756758 V value = entry .getValue ();
757759
@@ -781,8 +783,8 @@ public void onNext(Map.Entry<K, V> entry) {
781783
782784 @ Override
783785 public void onComplete () {
784- assert !onErrorCalled ;
785- onCompletedCalled = true ;
786+ assertState ( !onErrorCalled , () -> "onError has already been called; onComplete may not be invoked." ) ;
787+ onCompleteCalled = true ;
786788
787789 possiblyClearCacheEntriesOnExceptions (clearCacheKeys );
788790 List <V > values = new ArrayList <>(keys .size ());
@@ -795,7 +797,7 @@ public void onComplete() {
795797
796798 @ Override
797799 public void onError (Throwable ex ) {
798- assert ! onCompletedCalled ;
800+ assertState (! onCompleteCalled , () -> "onComplete has already been called; onError may not be invoked." ) ;
799801 onErrorCalled = true ;
800802
801803 stats .incrementBatchLoadExceptionCount (new IncrementBatchLoadExceptionCountStatisticsContext <>(keys , callContexts ));
0 commit comments