-
Bug
-
Resolution: Done
-
Major
-
None
-
3.14.0.Final
-
None
Default behavior:
- Building an MP REST client
- Request a resource that returns e.g. HTTP 503 status code (MP-Health endpoint which is down)
- A WebApplicationException is thrown
Alternate behavior:
- Building an MP REST client
- Register ResponseExceptionMapper which handles HTTP 503, but returns NULL for org.eclipse.microprofile.rest.client.ext.ResponseExceptionMapper#toThrowable
- Request a resource which returns HTTP 503
- A java.lang.reflect.UndeclaredThrowableException is thrown
Expected:
If I interpret it correctly, there should be no exception at all, according to https://github.com/eclipse/microprofile-rest-client/blob/1.4.1/spec/src/main/asciidoc/providers.asciidoc#how-to-implement-responseexceptionmapper.
This method may return null if no throwable should be raised.
Eventual source of evil:
org.jboss.resteasy.microprofile.client.ExceptionMapping.HandlerException
Some code:
public class Ignore503ExceptionMapper implements ResponseExceptionMapper<WebApplicationException> { @Override public WebApplicationException toThrowable(Response response) { return null; } @Override public boolean handles(int status, MultivaluedMap<String, Object> headers) { // as per MP-Health specification return 503 == status; } }
public interface HealthService extends Closeable { @GET @Produces({ MediaType.APPLICATION_JSON}) @Path("/health") HealthCheckData getHealthData(); }
RestClientBuilder.newBuilder()
.register(new Ignore503ExceptionMapper())
.build(HealthService.class)
.getHealthData();