Skip to content

Commit

Permalink
Make sure @ClientExceptionMapper works properly in native mode
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Feb 24, 2022
1 parent 36351d4 commit ede25f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ void registerProvidersFromAnnotations(CombinedIndexBuildItem indexBuildItem,
BuildProducer<GeneratedBeanBuildItem> generatedBeans,
BuildProducer<GeneratedClassBuildItem> generatedClasses,
BuildProducer<UnremovableBeanBuildItem> unremovableBeans,
BuildProducer<ReflectiveClassBuildItem> reflectiveClasses,
RestClientReactiveConfig clientConfig) {
String annotationRegisteredProvidersImpl = AnnotationRegisteredProviders.class.getName() + "Implementation";
IndexView index = indexBuildItem.getIndex();
Expand Down Expand Up @@ -292,6 +293,7 @@ void registerProvidersFromAnnotations(CombinedIndexBuildItem indexBuildItem,
+ "' is allowed per REST Client interface. Offending class is '" + result.interfaceName + "'");
}
ifaceToGeneratedMapper.put(result.interfaceName, result);
reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false, false, false, result.generatedClassName));
}

for (Map.Entry<String, List<AnnotationInstance>> annotationsForClass : annotationsByClassName.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
package io.quarkus.it.rest.client.main;

import javax.ws.rs.Consumes;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import io.quarkus.rest.client.reactive.ClientExceptionMapper;

@Path("")
public interface HelloClient {
@POST
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.TEXT_PLAIN)
String greeting(String name, @QueryParam("count") int count);

// this isn't used, but it makes sure that the generated provider can be properly instantiated in native mode
@ClientExceptionMapper
static RuntimeException toException(Response response) {
if (response.getStatus() == Response.Status.NOT_FOUND.getStatusCode()) {
return new NotFoundException("not found");
}
return null;
}
}

0 comments on commit ede25f8

Please sign in to comment.