-
Notifications
You must be signed in to change notification settings - Fork 210
Patching for Issue 143 #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,12 +15,14 @@ | |
| */ | ||
| package io.confluent.rest.validation; | ||
|
|
||
| import com.fasterxml.jackson.databind.DeserializationFeature; | ||
| import com.fasterxml.jackson.databind.JsonMappingException; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; | ||
| import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; | ||
|
|
||
| import javax.validation.ConstraintViolationException; | ||
| import javax.ws.rs.WebApplicationException; | ||
| import javax.ws.rs.core.MediaType; | ||
| import javax.ws.rs.core.MultivaluedMap; | ||
| import javax.ws.rs.ext.Provider; | ||
|
|
@@ -40,10 +42,13 @@ | |
| public class JacksonMessageBodyProvider extends JacksonJaxbJsonProvider { | ||
|
|
||
| public JacksonMessageBodyProvider() { | ||
| setMapper(new ObjectMapper()); | ||
| ObjectMapper mapper = new ObjectMapper(); | ||
| mapper.enable(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY); | ||
| setMapper(mapper); | ||
| } | ||
|
|
||
| public JacksonMessageBodyProvider(ObjectMapper mapper) { | ||
| mapper.enable(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY); | ||
| setMapper(mapper); | ||
| } | ||
|
|
||
|
|
@@ -77,6 +82,8 @@ public Object readFrom(Class<Object> type, | |
| Throwable cause = e.getCause(); | ||
| if (cause instanceof ConstraintViolationException) { | ||
| throw (ConstraintViolationException) cause; | ||
| }else if(cause instanceof WebApplicationException){ | ||
|
||
| throw (WebApplicationException) cause; | ||
| } | ||
| throw e; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forcibly overriding this seems to be counter to the goal of this constructor, which is to allow the user to get control over the exact settings of the
ObjectMapper. Is there any reason this needs to be overridden here? If the caller chose to leaveFAIL_ON_READING_DUP_TREE_KEYoff, is there any reason not to respect that?This might require adjustments to kafka-rest to address the issue that triggered this PR, but keep in mind this class is used across a few projects and some might not need to be as restrictive and might prefer being a bit more liberal with the input they accept.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I was thinking having a single key per record to be produced is the requirement, as defined in the API reference page. Key should be uniquely identify a record. However, I think other REST function may also use this to parse their request, which may allow duplicated meta-data. I will change it back.