You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ranger.apache.org by "Sercan Tekin (Jira)" <ji...@apache.org> on 2023/05/05 03:06:00 UTC

[jira] [Updated] (RANGER-4225) Possible Jackson serialization issue due to not complain to Java bean standards

     [ https://issues.apache.org/jira/browse/RANGER-4225?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sercan Tekin updated RANGER-4225:
---------------------------------
    Summary: Possible Jackson serialization issue due to not complain to Java bean standards  (was: Possible Jackson serialization due to not complain to Java bean standards)

> Possible Jackson serialization issue due to not complain to Java bean standards
> -------------------------------------------------------------------------------
>
>                 Key: RANGER-4225
>                 URL: https://issues.apache.org/jira/browse/RANGER-4225
>             Project: Ranger
>          Issue Type: Bug
>          Components: Ranger
>            Reporter: Sercan Tekin
>            Assignee: Sercan Tekin
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> *PROBLEM:*
> Transitive Jackson-2 dependencies are included into Ranger's classpath in my env and conflicted with Jackson-1 dependencies.
> Jackson-2 uses Javabean naming conventions to figure out the Json properties in a Java class and some of the Ranger's model classes don't comply with the convention.
> For example, when the leading camelcase word is only one letter in length, then deserialized response is broken. The following is what I observed in Ranger;
> On Ranger UI side, this [code-block|https://github.com/apache/ranger/blob/ranger-1.2/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js#L224-L229] attempts to read vXStrings key in map, but the corresponding response has vxstrings:
> {code:java}
> {
>     "startIndex": 0,
>     "pageSize": 200,
>     "totalCount": 11,
>     "resultSize": 11,
>     "sortType": "asc",
>     "sortBy": "id",
>     "listSize": 11,
>     "vxstrings": [        <==================== here! This has to be vXStrings
>         {
>             "value": "public",
>             ... {code}
> And this difference causes below issue while reading the property, therefore the corresponding dropdown has no values as excepted;
> {code:java}
> PermissionList.js?ver=build.version:226 Uncaught TypeError: Cannot read properties of undefined (reading 'map')
>     at Object.results (PermissionList.js?ver=build.version:226:34)
>     at Object.success (select2.js?ver=build.version:450:47)
>     at u (jquery-3.3.1.min.js?ver=build.version:2:27457)
>     at Object.fireWith [as resolveWith] (jquery-3.3.1.min.js?ver=build.version:2:28202)
>     at k (jquery-3.3.1.min.js?ver=build.version:2:77651)
>     at XMLHttpRequest.<anonymous> (jquery-3.3.1.min.js?ver=build.version:2:79907){code}
> *REFERENCES:*
> Please see this reference related to capital letters [http://futuretask.blogspot.com/2005/01/java-tip-6-dont-capitalize-first-two.html]
> "Don't capitalize first two letters of a bean property name. This is in our java standards. You should not create a java bean property name that begins with a capital letter in the 1st two places."
> Also you can see the same issue is reported here [https://stackoverflow.com/questions/30205006/why-does-jackson-2-not-recognize-the-first-capital-letter-if-the-leading-camel-c] 
> *SOLUTION:*
> {{@JsonProperty}} annotation needs to be added for mapping the properties with their corresponding getter/setter methods. This will not effect Ranger's functionality directly, but it will provide consistency even if Jackson-2 is included into classpath.
> I have tested it locally after adding {{@JsonProperty}} and everything worked well.
> I will be providing a PR.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)