-
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.
Allows users to exclude DefaultMismatchedInputException
A few users have run into an issue where they are trying to handle all Jackson exceptions but the existence of DefaultMismatchedInputException prevents that for MismatchedInputException (as per JAX-RS / Jakarta REST rules). This change allows users to do use: quarkus.class-loading.removed-resources."io.quarkus\:quarkus-rest-jackson"=io/quarkus/resteasy/reactive/jackson/runtime/mappers/DefaultMismatchedInputException.class in order to have Quarkus ignore the mapper.
- Loading branch information
Showing
3 changed files
with
58 additions
and
4 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
46 changes: 46 additions & 0 deletions
46
...kson/deployment/test/ExceptionInReaderWithExcludedBuiltInAndIncludedCustomMapperTest.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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.quarkus.resteasy.reactive.jackson.deployment.test; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import jakarta.ws.rs.core.Response; | ||
import jakarta.ws.rs.ext.ExceptionMapper; | ||
import jakarta.ws.rs.ext.Provider; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import com.fasterxml.jackson.databind.DatabindException; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class ExceptionInReaderWithExcludedBuiltInAndIncludedCustomMapperTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setArchiveProducer(new Supplier<>() { | ||
@Override | ||
public JavaArchive get() { | ||
return ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(FroMage.class, FroMageEndpoint.class, DatabindExceptionMapper.class); | ||
} | ||
}).overrideConfigKey("quarkus.class-loading.removed-resources.\"io.quarkus\\:quarkus-rest-jackson\"", | ||
"io/quarkus/resteasy/reactive/jackson/runtime/mappers/DefaultMismatchedInputException.class"); | ||
|
||
@Test | ||
public void test() { | ||
RestAssured.with().contentType("application/json").body("{\"name\": \"brie\"}").put("/fromage") | ||
.then().statusCode(999); | ||
} | ||
|
||
@Provider | ||
public static class DatabindExceptionMapper implements ExceptionMapper<DatabindException> { | ||
|
||
@Override | ||
public Response toResponse(DatabindException exception) { | ||
return Response.status(999).build(); | ||
} | ||
} | ||
} |
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