@@ -2708,15 +2708,22 @@ public void onConnectionClosed(Transport.Connection connection) {
2708
2708
}
2709
2709
}
2710
2710
2711
+ public void testFailToSendTransportException () throws InterruptedException {
2712
+ TransportException exception = doFailToSend (new TransportException ("fail to send" ));
2713
+ assertThat (exception .getMessage (), equalTo ("fail to send" ));
2714
+ assertThat (exception .getCause (), nullValue ());
2715
+ }
2716
+
2717
+ public void testFailToSendIllegalStateException () throws InterruptedException {
2718
+ TransportException exception = doFailToSend (new IllegalStateException ("fail to send" ));
2719
+ assertThat (exception , instanceOf (SendRequestTransportException .class ));
2720
+ assertThat (exception .getMessage (), containsString ("fail-to-send-action" ));
2721
+ assertThat (exception .getCause (), instanceOf (IllegalStateException .class ));
2722
+ assertThat (exception .getCause ().getMessage (), equalTo ("fail to send" ));
2723
+ }
2724
+
2711
2725
// test that the response handler is invoked on a failure to send
2712
- @ AwaitsFix (bugUrl = "https://github.com/elastic/elasticsearch/issues/75209" )
2713
- public void testFailToSend () throws InterruptedException {
2714
- final RuntimeException failToSendException ;
2715
- if (randomBoolean ()) {
2716
- failToSendException = new IllegalStateException ("fail to send" );
2717
- } else {
2718
- failToSendException = new TransportException ("fail to send" );
2719
- }
2726
+ private TransportException doFailToSend (RuntimeException failToSendException ) throws InterruptedException {
2720
2727
final TransportInterceptor interceptor = new TransportInterceptor () {
2721
2728
@ Override
2722
2729
public AsyncSender interceptSender (final AsyncSender sender ) {
@@ -2752,7 +2759,7 @@ public void onResponse(final Void v) {
2752
2759
public void onFailure (final Exception e ) {
2753
2760
fail (e .getMessage ());
2754
2761
}
2755
- });
2762
+ });
2756
2763
latch .await ();
2757
2764
final AtomicReference <TransportException > te = new AtomicReference <>();
2758
2765
final Transport .Connection connection = serviceC .getConnection (nodeA );
@@ -2773,17 +2780,8 @@ public void handleException(final TransportException exp) {
2773
2780
}
2774
2781
});
2775
2782
assertThat (te .get (), not (nullValue ()));
2776
-
2777
- if (failToSendException instanceof IllegalStateException ) {
2778
- assertThat (te .get ().getMessage (), equalTo ("failure to send" ));
2779
- assertThat (te .get ().getCause (), instanceOf (IllegalStateException .class ));
2780
- assertThat (te .get ().getCause ().getMessage (), equalTo ("fail to send" ));
2781
- } else {
2782
- assertThat (te .get ().getMessage (), equalTo ("fail to send" ));
2783
- assertThat (te .get ().getCause (), nullValue ());
2784
- }
2783
+ return te .get ();
2785
2784
}
2786
-
2787
2785
}
2788
2786
2789
2787
private void closeConnectionChannel (Transport .Connection connection ) {
0 commit comments