@@ -177,24 +177,27 @@ public void testInternalSendExceptionForksToGenericIfHandlerDoesNotForkAndStackO
177177 );
178178 }
179179
180- public void testInternalSendExceptionWithNonForkingResponseHandlerCanCompleteFutureWaiterFromGenericThread () throws Exception {
180+ public void testInternalSendExceptionWithNonForkingResponseHandlerCompletesListenerInline () {
181181 try (var nodeA = new TestNode ("node-A" )) {
182- final var future = new PlainActionFuture <TransportResponse .Empty >();
183- nodeA .transportService .getThreadPool ().generic ().execute (() -> {
184- assertEquals ("simulated exception in sendRequest" , getSendRequestException (future , IOException .class ).getMessage ());
185- });
186182 final Thread callingThread = Thread .currentThread ();
187- nodeA .transportService .sendRequest (
188- nodeA .getThrowingConnection (),
189- TestNode .randomActionName (random ()),
190- new EmptyRequest (),
191- TransportRequestOptions .EMPTY ,
192- new ActionListenerResponseHandler <>(future .delegateResponse ((l , e ) -> {
193- assertThat (Thread .currentThread (), is (callingThread ));
194- l .onFailure (e );
195- }), unusedReader (), EsExecutors .DIRECT_EXECUTOR_SERVICE )
183+ assertEquals (
184+ "simulated exception in sendRequest" ,
185+ safeAwaitAndUnwrapFailure (
186+ IOException .class ,
187+ TransportResponse .Empty .class ,
188+ l -> nodeA .transportService .sendRequest (
189+ nodeA .getThrowingConnection (),
190+ TestNode .randomActionName (random ()),
191+ new EmptyRequest (),
192+ TransportRequestOptions .EMPTY ,
193+ new ActionListenerResponseHandler <>(
194+ ActionListener .runBefore (l , () -> assertSame (callingThread , Thread .currentThread ())),
195+ unusedReader (),
196+ EsExecutors .DIRECT_EXECUTOR_SERVICE
197+ )
198+ )
199+ ).getMessage ()
196200 );
197- assertBusy (() -> assertTrue (future .isDone ()));
198201 }
199202 }
200203
0 commit comments