-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure @ClientExceptionMapper works properly in native mode
Fixes: #23766
- Loading branch information
Showing
2 changed files
with
15 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...-tests/rest-client-reactive/src/main/java/io/quarkus/it/rest/client/main/HelloClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |