@@ -563,40 +563,50 @@ 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
@@ -607,50 +617,66 @@ public void onDiscardSummary(DiscardSummary summary) {
607
617
608
618
@ Override
609
619
public void onCommitSummary (CommitSummary summary ) {
610
- runIgnoringError (() -> delegate .onCommitSummary (summary ));
611
- handleSummary ();
620
+ if (!summariesFuture .isDone ()) {
621
+ runIgnoringError (() -> delegate .onCommitSummary (summary ));
622
+ handleSummary ();
623
+ }
612
624
}
613
625
614
626
@ Override
615
627
public void onRollbackSummary (RollbackSummary summary ) {
616
- runIgnoringError (() -> delegate .onRollbackSummary (summary ));
617
- handleSummary ();
628
+ if (!summariesFuture .isDone ()) {
629
+ runIgnoringError (() -> delegate .onRollbackSummary (summary ));
630
+ handleSummary ();
631
+ }
618
632
}
619
633
620
634
@ Override
621
635
public void onResetSummary (ResetSummary summary ) {
622
- runIgnoringError (() -> delegate .onResetSummary (summary ));
623
- handleSummary ();
636
+ if (!summariesFuture .isDone ()) {
637
+ runIgnoringError (() -> delegate .onResetSummary (summary ));
638
+ handleSummary ();
639
+ }
624
640
}
625
641
626
642
@ Override
627
643
public void onRouteSummary (RouteSummary summary ) {
628
- runIgnoringError (() -> delegate .onRouteSummary (summary ));
629
- handleSummary ();
644
+ if (!summariesFuture .isDone ()) {
645
+ runIgnoringError (() -> delegate .onRouteSummary (summary ));
646
+ handleSummary ();
647
+ }
630
648
}
631
649
632
650
@ Override
633
651
public void onLogoffSummary (LogoffSummary summary ) {
634
- runIgnoringError (() -> delegate .onLogoffSummary (summary ));
635
- handleSummary ();
652
+ if (!summariesFuture .isDone ()) {
653
+ runIgnoringError (() -> delegate .onLogoffSummary (summary ));
654
+ handleSummary ();
655
+ }
636
656
}
637
657
638
658
@ Override
639
659
public void onLogonSummary (LogonSummary summary ) {
640
- runIgnoringError (() -> delegate .onLogonSummary (summary ));
641
- handleSummary ();
660
+ if (!summariesFuture .isDone ()) {
661
+ runIgnoringError (() -> delegate .onLogonSummary (summary ));
662
+ handleSummary ();
663
+ }
642
664
}
643
665
644
666
@ Override
645
667
public void onTelemetrySummary (TelemetrySummary summary ) {
646
- runIgnoringError (() -> delegate .onTelemetrySummary (summary ));
647
- handleSummary ();
668
+ if (!summariesFuture .isDone ()) {
669
+ runIgnoringError (() -> delegate .onTelemetrySummary (summary ));
670
+ handleSummary ();
671
+ }
648
672
}
649
673
650
674
@ Override
651
675
public void onIgnored () {
652
- runIgnoringError (delegate ::onIgnored );
653
- handleSummary ();
676
+ if (!summariesFuture .isDone ()) {
677
+ runIgnoringError (delegate ::onIgnored );
678
+ handleSummary ();
679
+ }
654
680
}
655
681
656
682
@ Override
0 commit comments