question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rest-Client-Reactive: Custom `WebApplicationExceptions` not accessable by MP-Fault-Tolerance

See original GitHub issue

Describe the bug

When using the retry mechanism of MP-Fault-Tolerance you usually do not want to retry on Status 400, i.e. bad requests. To achieve that, I annotated a method with @Retry(abortOn = BadRequestException.class) and converted 400 responses to a BadRequestException in a custom ResponseExceptionMapper<WebApplicationException>. That used to work with the old “Resteasy client”. Unfortunately, with Rest-Client-Reactive all WebApplicationExceptions are wrapped by corresponding ClientWebApplicationExceptions, so that the Retry is not able to distinguish between response codes.

See https://github.com/quarkusio/quarkus/issues/22777 for another issue regarding exception wrapping.

Expected behavior

Custom WebApplicationException types are passed through for interceptors like Retry

Actual behavior

All WebApplicationExceptions are converted to ClientWebApplicationExceptions

How to Reproduce?

@RegisterRestClient
@RegisterProvider(RestView.BadRequestExceptionMapper.class)
public interface RestView {
    @POST
    @Path("/test")
    @Retry(abortOn = BadRequestException.class)
    String test(String param);

    class BadRequestExceptionMapper implements ResponseExceptionMapper<WebApplicationException> {
        @Override
        public WebApplicationException toThrowable(Response response) {
            return new BadRequestException();
        }

        @Override
        public boolean handles(int status, MultivaluedMap<String, Object> headers) {
            return status == HttpStatus.SC_BAD_REQUEST;
        }
    }
}

Output of uname -a or ver

Microsoft Windows [Version 10.0.19042.1415]

Output of java -version

openjdk version “11.0.3” 2019-04-16 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.3+7, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.6.1.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f)

Additional information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Ladicekcommented, Feb 9, 2022

This is fixed in SmallRye Fault Tolerance 5.3.0, where in the non-compatible mode (which is on by default in Quarkus), exception cause chains are inspected.

0reactions
Ladicekcommented, Jan 24, 2022

There’s no release yet. There will be one soon, but it won’t make it into 2.7.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rest Client for MicroProfile
This simple API exposes one API call, located at /greet from the base URL of the client. Invoking this endpoint returns a javax.ws.rs.core....
Read more >
RestClient Error javax.ws.rs.WebApplicationException
If I understood correctly this issue, when RestClient receives one response different from 2xx it automatically throws this exception.
Read more >
Asynchronous REST with JAX-RS and MicroProfile
JAX-RS and MicroProfile Rest Client make writing and consuming RESTful services both easy and powerful, especially when using their ...
Read more >
Asynchronous REST With JAX-RS and MicroProfile - DZone
A software developer provides a tutorial on how to use open source MicroProfile platform to both write and consume RESTful services ...
Read more >
Page 2 – Enterprise Java and More - Andy McCright
Previous releases of MicroProfile Rest Client lacked integration with CDI, Fault Tolerance, OpenTracing, etc. making it difficult to add ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found