Skip to content

Commit

Permalink
Merge pull request #23936 from geoand/#23766-again
Browse files Browse the repository at this point in the history
Make sure @ClientExceptionMapper works properly in native mode
  • Loading branch information
geoand committed Feb 25, 2022
2 parents 77a14d4 + ede25f8 commit 8d82223
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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
@@ -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 8d82223

Please sign in to comment.