@@ -563,94 +563,122 @@ private ResponseHandleImpl(ResponseHandler delegate, int expectedSummaries) {
563
563
@ Override
564
564
public void onError (Throwable throwable ) {
565
565
if (!(throwable instanceof MessageIgnoredException )) {
566
- runIgnoringError (() -> delegate .onError (throwable ));
567
- if (!(throwable instanceof Neo4jException )
568
- || throwable instanceof ServiceUnavailableException
569
- || throwable instanceof ProtocolException ) {
570
- // assume unrecoverable error, ensure onComplete
571
- expectedSummaries = 1 ;
566
+ if (!summariesFuture .isDone ()) {
567
+ runIgnoringError (() -> delegate .onError (throwable ));
568
+ if (!(throwable instanceof Neo4jException )
569
+ || throwable instanceof ServiceUnavailableException
570
+ || throwable instanceof ProtocolException ) {
571
+ // assume unrecoverable error, ensure onComplete
572
+ expectedSummaries = 1 ;
573
+ }
574
+ handleSummary ();
572
575
}
573
- handleSummary ();
574
576
} else {
575
577
onIgnored ();
576
578
}
577
579
}
578
580
579
581
@ Override
580
582
public void onBeginSummary (BeginSummary summary ) {
581
- runIgnoringError (() -> delegate .onBeginSummary (summary ));
582
- handleSummary ();
583
+ if (!summariesFuture .isDone ()) {
584
+ runIgnoringError (() -> delegate .onBeginSummary (summary ));
585
+ handleSummary ();
586
+ }
583
587
}
584
588
585
589
@ Override
586
590
public void onRunSummary (RunSummary summary ) {
587
- runIgnoringError (() -> delegate .onRunSummary (summary ));
588
- handleSummary ();
591
+ if (!summariesFuture .isDone ()) {
592
+ runIgnoringError (() -> delegate .onRunSummary (summary ));
593
+ handleSummary ();
594
+ }
589
595
}
590
596
591
597
@ Override
592
598
public void onRecord (Value [] fields ) {
593
- runIgnoringError (() -> delegate .onRecord (fields ));
599
+ if (!summariesFuture .isDone ()) {
600
+ runIgnoringError (() -> delegate .onRecord (fields ));
601
+ }
594
602
}
595
603
596
604
@ Override
597
605
public void onPullSummary (PullSummary summary ) {
598
- runIgnoringError (() -> delegate .onPullSummary (summary ));
599
- handleSummary ();
606
+ if (!summariesFuture .isDone ()) {
607
+ runIgnoringError (() -> delegate .onPullSummary (summary ));
608
+ handleSummary ();
609
+ }
600
610
}
601
611
602
612
@ Override
603
613
public void onDiscardSummary (DiscardSummary summary ) {
604
- runIgnoringError (() -> delegate .onDiscardSummary (summary ));
605
- handleSummary ();
614
+ if (!summariesFuture .isDone ()) {
615
+ runIgnoringError (() -> delegate .onDiscardSummary (summary ));
616
+ handleSummary ();
617
+ }
606
618
}
607
619
608
620
@ Override
609
621
public void onCommitSummary (CommitSummary summary ) {
610
- runIgnoringError (() -> delegate .onCommitSummary (summary ));
611
- handleSummary ();
622
+ if (!summariesFuture .isDone ()) {
623
+ runIgnoringError (() -> delegate .onCommitSummary (summary ));
624
+ handleSummary ();
625
+ }
612
626
}
613
627
614
628
@ Override
615
629
public void onRollbackSummary (RollbackSummary summary ) {
616
- runIgnoringError (() -> delegate .onRollbackSummary (summary ));
617
- handleSummary ();
630
+ if (!summariesFuture .isDone ()) {
631
+ runIgnoringError (() -> delegate .onRollbackSummary (summary ));
632
+ handleSummary ();
633
+ }
618
634
}
619
635
620
636
@ Override
621
637
public void onResetSummary (ResetSummary summary ) {
622
- runIgnoringError (() -> delegate .onResetSummary (summary ));
623
- handleSummary ();
638
+ if (!summariesFuture .isDone ()) {
639
+ runIgnoringError (() -> delegate .onResetSummary (summary ));
640
+ handleSummary ();
641
+ }
624
642
}
625
643
626
644
@ Override
627
645
public void onRouteSummary (RouteSummary summary ) {
628
- runIgnoringError (() -> delegate .onRouteSummary (summary ));
629
- handleSummary ();
646
+ if (!summariesFuture .isDone ()) {
647
+ runIgnoringError (() -> delegate .onRouteSummary (summary ));
648
+ handleSummary ();
649
+ }
630
650
}
631
651
632
652
@ Override
633
653
public void onLogoffSummary (LogoffSummary summary ) {
634
- runIgnoringError (() -> delegate .onLogoffSummary (summary ));
635
- handleSummary ();
654
+ if (!summariesFuture .isDone ()) {
655
+ runIgnoringError (() -> delegate .onLogoffSummary (summary ));
656
+ handleSummary ();
657
+ }
636
658
}
637
659
638
660
@ Override
639
661
public void onLogonSummary (LogonSummary summary ) {
640
- runIgnoringError (() -> delegate .onLogonSummary (summary ));
641
- handleSummary ();
662
+ if (!summariesFuture .isDone ()) {
663
+ runIgnoringError (() -> delegate .onLogonSummary (summary ));
664
+ handleSummary ();
665
+ }
642
666
}
643
667
644
668
@ Override
645
669
public void onTelemetrySummary (TelemetrySummary summary ) {
646
- runIgnoringError (() -> delegate .onTelemetrySummary (summary ));
647
- handleSummary ();
670
+ if (!summariesFuture .isDone ()) {
671
+ runIgnoringError (() -> delegate .onTelemetrySummary (summary ));
672
+ handleSummary ();
673
+ }
648
674
}
649
675
650
676
@ Override
651
677
public void onIgnored () {
652
- runIgnoringError (delegate ::onIgnored );
653
- handleSummary ();
678
+ if (!summariesFuture .isDone ()) {
679
+ runIgnoringError (delegate ::onIgnored );
680
+ handleSummary ();
681
+ }
654
682
}
655
683
656
684
@ Override
0 commit comments