-
Notifications
You must be signed in to change notification settings - Fork 931
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
RANGER-4225: Possible Jackson serialization issue due to not comply with Java bean standards #252
base: master
Are you sure you want to change the base?
Conversation
602a07d
to
77fac4d
Compare
@kumaab could you please take a look at this? |
@mneethiraj could you please take a look at this? I hit this issue earlier, and the solution here can save some grief for the end-users for the future. |
05c4764
to
e68a9a1
Compare
e68a9a1
to
0da66da
Compare
LGTM. Kindly resolve the conflict. |
(cherry picked from commit 2f6cf7a)
…ith Java bean standards
0da66da
to
54239ad
Compare
@bhavikpatel9977, thank you for reviewing the PR. I have resolved the conflict and quickly tested it again.
|
@mneethiraj Can you kindly review once |
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.
@sercanCyberVision - thank you for taking up this critical update to switch to fasterxml.jackson. In addition to the couple of review comments, can you please verify that the final packaging does not include codehaus jackson library? It seems Ranger admin continues to use codehaus jackson library to serialize REST API responses. For example, the response includes fields having null and empty value.
@@ -91,7 +91,7 @@ | |||
<cglib.version>2.2.0-b23</cglib.version> | |||
<checkstyle.plugin.version>3.1.0</checkstyle.plugin.version> | |||
<checkstyle.version>8.29</checkstyle.version> | |||
<codehaus.jackson.version>1.9.13</codehaus.jackson.version> | |||
<com.fasterxml.jackson.version>2.17.0</com.fasterxml.jackson.version> <!--here--> |
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.
import com.fasterxml.jackson.annotation.JsonAutoDetect; | ||
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
|
||
|
||
@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY) |
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.
With the move to fasterxml.jackson 2.x, consider replacing deprecated include = JsonSerialize.Inclusion.NON_EMPTY
, with @JsonInclude(JsonInclude.Include.NON_EMPTY)
What changes were proposed in this pull request?
@JsonProperty
annotation has been added to model classes for mapping the properties with their corresponding getter/setter methods. This will not effect Ranger's functionality directly, but it will provide consistency in case there is Jackson jar conflict (or when/if Jackson is upgraded to version-2).Please see the Jira for more detailed analysis of the issue https://issues.apache.org/jira/browse/RANGER-4225
Basically, some of the model classes do not comply with JavaBean naming conventions, therefore it is possible that Ranger may hit this issue https://stackoverflow.com/questions/30205006/why-does-jackson-2-not-recognize-the-first-capital-letter-if-the-leading-camel-c
As a reference of the issue, please see http://futuretask.blogspot.com/2005/01/java-tip-6-dont-capitalize-first-two.html
How was this patch tested?
Built the project and made sure that deserialized responses on UI side have correct property names even though Jackson-2 jars are in the classpath, hence the corresponding UI components work as expected.