Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MP Fault Tolerance - default method fallback doesn't work in native mode #14394

Closed
pjgg opened this issue Jan 19, 2021 · 8 comments · Fixed by #15788
Closed

MP Fault Tolerance - default method fallback doesn't work in native mode #14394

pjgg opened this issue Jan 19, 2021 · 8 comments · Fixed by #15788
Assignees
Milestone

Comments

@pjgg
Copy link
Contributor

pjgg commented Jan 19, 2021

Summary
I have a microprofile HttpClient on Native mode, and also a fallback action configured, then I got the following exception:

2021-01-18 10:36:17,661 ERROR [org.jbo.res.res.i18n] (executor-thread-1) RESTEASY002020: Unhandled asynchronous exception, sending back 500: java.lang.RuntimeException: Not implemented in native mode

Expected behavior
Same as JVM mode (if HTTP request fail, then move on to fallback)

Actual behavior

2021-01-18 10:36:17,661 ERROR [org.jbo.res.res.i18n] (executor-thread-1) RESTEASY002020: Unhandled asynchronous exception, sending back 500: java.lang.RuntimeException: Not implemented in native mode

To Reproduce

Setup an HttpClient pointing to a not found URL

@RegisterRestClient(baseUri = "http://microprofile-test:8080/")
public interface HelloClient {
    
    @GET
    @Path("/hello/notFound")
    @Produces(MediaType.TEXT_PLAIN)
    @Asynchronous
    @Fallback(fallbackMethod = "fallback")
    CompletionStage<String> getWithFallback();

    default CompletionStage<String> fallback() {
        return completedFuture("Fallback");
    }
}

And then make a query:

@Inject
@RestClient
HelloClient hello;

hello.getWithFallback().thenApply(result -> "Client got: " + result);

Jira ref

@pjgg pjgg added the kind/bug Something isn't working label Jan 19, 2021
@ghost ghost added the triage/needs-triage label Jan 19, 2021
@mkouba mkouba changed the title Microprofile fallback, doesn't work on Native mode. MP Fault Tolerance - default method fallback doesn't work in native mode Jan 19, 2021
@mkouba
Copy link
Contributor

mkouba commented Jan 19, 2021

CC @Ladicek

SmallRye has a workaround for default fallback methods: io.smallrye.faulttolerance.DefaultMethodFallbackProvider.getFallback(Method, ExecutionContextWithInvocationContext). However, this may not work in native mode and therefore the method is substituted in io.quarkus.smallrye.faulttolerance.runtime.graal.Target_io_smallrye_faulttolerance_DefaultMethodFallbackProvider.getFallback().

@Ladicek Ladicek self-assigned this Jan 19, 2021
@Ladicek
Copy link
Contributor

Ladicek commented Jan 19, 2021

Yea I've noticed that, and chose to forget about it because supporting it will probably require non-trivial changes in SRye FT :-) Assigning to myself, but it will take a bit of time.

@geoand
Copy link
Contributor

geoand commented Feb 17, 2021

I think in GraalVM 21 support method handles better now so maybe this can be re-examined?

@rsvoboda
Copy link
Member

@Ladicek can you look into this regression again? Quarkus is on GraalVM 21 now.

@Ladicek
Copy link
Contributor

Ladicek commented Mar 16, 2021

I'll try (remove the substitution and verify), but no promises if it doesn't work out :-)

@Ladicek
Copy link
Contributor

Ladicek commented Mar 16, 2021

Confirm that with GraalVM 21 and the substitution removed, it works. I'll take a look where to add a test and submit a PR.

@Ladicek
Copy link
Contributor

Ladicek commented Mar 16, 2021

Submitted #15788.

@Ladicek
Copy link
Contributor

Ladicek commented Mar 16, 2021

Also, let's make one thing clear: this is not a regression. This has never worked :-)

@quarkus-bot quarkus-bot bot added this to the 1.13 - main milestone Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants