Quarkus: Rest Client does not propagate errors correctly in Async mode (Uni, RxJava)

Created on 12 Apr 2020  Â·  12Comments  Â·  Source: quarkusio/quarkus

Describe the bug
It seems that when using the asynchronous REST Client operators (either CompletionStage, rxJava 2.x operators, or the Mutiny operators), when the REST client encounters an error like 404, it is not able to call any exception mappers correctly, thus making it impossible to handle any HTTP errors from the rest client.

This was reported before, and either the fix applied was not working correctly, or there is a regression.

To Reproduce
Steps to reproduce the behavior:

  1. Open and run the attached project
  2. Call http://localhost:8080/country/sync
  3. The 404 error is propagated to the result.
  4. Now call http://localhost:8080/country/async
  5. Note that the error is a generic 500. The logs mention "Handled Internally". There is no way to figure our what went wrong in the async mode.

* Expected Outcome *
The async REST call should properly propagate the 404 error, just like the synchronous call does.

Environment (please complete the following information):
Quarkus 1.3.2.Final, OS X 10.15, Java 11 OpenJDK.

Additional context
(Add any other context about the problem here.)
Previously reported in https://github.com/quarkusio/quarkus/issues/3655 - the issue seems to be closed after a fix was applied, but the issue persists.

error.zip

kinbug

Most helpful comment

Is there any updates on this issue?
@csotiriou

All 12 comments

This is slightly different, because it actually works with CompletionStage, but not with Uni.

So yeah, this was fixed in AsyncInterceptorRxInvoker which extends CompletionStageRxInvokerImpl and is installed by AsyncInterceptorRxInvokerProvider.

Now, we have a UniInvokerProvider which returns a UniRxInvokerImpl based off the CompletionStageRxInvoker which it gets from the ClientInvocationBuilder, which is not the right subtype, so it also doesn't apply interceptors. I believe this is wrong.

This appears to be a bug split between Mutiny (@cescoffier), RESTEasy client (@asoldano) and MP REST client (@kenfinnigan).

Probably MpClientInvocationBuilder needs to override:

   @Override
   public CompletionStageRxInvoker rx()
   {
      return new CompletionStageRxInvokerImpl(this, invocation.getClient().asyncInvocationExecutor());
   }

To return its own AsyncInterceptorRxInvoker type instead, which is what rx(CompletionStage.class) would have returned.

@phillip-kruger FYI

@FroMage you are right, my bad. CompletionStage works fine, but it seems that RxJava and Mutiny operators don't. I changed the title and made the necessary edits.

From https://issues.redhat.com/browse/RESTEASY-2558:

Quarkus needs to provide a CompletionCallback to AbstractAsynchronousResponse
so it has something to hand the exception to. See lines 166-169 in
AbstractAsynchronousResponse.completionCallbacks

Looks like your addition needs to be made after line 105 in
io.quarkus.resteasy.runtime.standalone.VertxRequestHandler

vertxRequest.getAsyncContext().getAsyncResponse().register(CompletionCallback)

The line number (105) refer to v 1.3.2 and not current master. This is in RESTEasy extension.

Uh… was my fix not sufficient, then?

I'll comment on the issue.

@FroMage Not sure about your fix, but I can still create the issue using the error.zip attached above and master (999-SNAPSHOT) Quarkus

Is there any updates on this issue?
@csotiriou

@shireenmagdy @FroMage The issue still persists in Quarkus 1.8.3. We decided to put a ClientRequestFilter to catch the error and propagate it gracefully ourselves, until this is fixed.

EDIT: I guess we will have to wait for this PR to be merged and integrated into Quarkus? https://github.com/resteasy/Resteasy/pull/2554

Was this page helpful?
0 / 5 - 0 ratings