-
Notifications
You must be signed in to change notification settings - Fork 979
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
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. |
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.
pom.xml
Outdated
@@ -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.
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.
Thank you @mneethiraj for your review.
I have implemented above requested change and pushed it as a separate commit for now as it is easier for you to see the difference, the commit is cccbabf.
If needed, when we reach the final state, I can squash the commits or change the names.
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)
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.
As stated above, the changes have been implemented with cccbabf commit.
54239ad
to
7eb06a5
Compare
Thank you @mneethiraj for detailed review. You are right; codehaus.jackson was present in the admin library. I have checked the dependency tree and found that they were transitive. I have fixed the issue with this separate commit: 7eb06a5. If needed, we can squash it once the review is completed. I kept it separate so you can see the changes easily. The latest state is as follows:
I have one concern: when I deploy the project locally with Docker, I see the following issue on some endpoints after removing transitive dependencies: However, I'm not sure if this is a real issue because when I saw the issue previously, others did not see it with the same codebase. For example, when I mentioned the issue here, in the next comment, the same codebase worked on another machine. Could you please check on your end? |
@sercanCyberVision - the error is likely due to missing Json provider in Ranger admin server. A provider should be implemented in Ranger servers like admin/KMS. In addition, Ranger client libraries should be updated to replace calls to ClientResponse.getEntity(cls) with JsonUtilsV2.jsonToObj(jsonStr, cls). I added these fixes on top of the changes in this PR, and created a .patch file that applies on the latest master branch. I will attach this file in RANGER-4225 shortly. Can you please review/verify these updates and create a new PR? Thank you again for driving this critical update. |
…ith Java bean standards
7eb06a5
to
f84dd02
Compare
@mneethiraj, thank you for providing the fix. I have modified this PR for the complete solution. At the moment, I see that everything is working fine on my end. However, I still see some Checks on UI: |
@sercanCyberVision - good catch on use of One more issue I noticed was that the patch replaced NOT_NULL to NOT_EMPTY in several classes; this caused errors in UI as the response from server didn't include empty collection values - [] or {}. I updated the patch to address above issues and will attach in RANGER-4225. |
The final patch is in the review board at https://reviews.apache.org/r/75082/. The patch is merged in master and ranger-2.5 branches. |
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.