Skip to content
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

[BUG] FlatteningSerializer not work correctly for Map/List with final modifier #20150

Closed
3 tasks done
weidongxu-microsoft opened this issue Mar 26, 2021 · 3 comments
Closed
3 tasks done
Assignees
Labels
Azure.Core azure-core
Milestone

Comments

@weidongxu-microsoft
Copy link
Member

weidongxu-microsoft commented Mar 26, 2021

Describe the bug
A clear and concise description of what the bug is.

It breaks the "dot" in Map key, result in e.g. {"operation":"Replace","properties":{"tags":{"tag":{"1":"value.1"}}}}

Sample case #20149

Code on https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/core/azure-core/src/main/java/com/azure/core/util/serializer/FlatteningSerializer.java#L106-L122

It happens to track1, reported by Databricks. Checked on track2, still reproducible (though it is now limited to classes annotated with @JsonFlatten).

I am not able to find good solution for this, as the Map or List might not even be modifiable.

Exception or Stack Trace
Add the exception log and stack trace if available

To Reproduce
Steps to reproduce the behavior:

Sample case #20149

Code Snippet
Add the code snippet that causes the issue.

Sample case #20149

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • OS: [e.g. iOS]
  • IDE : [e.g. IntelliJ]
  • Version of the Library used: azure-core 1.14.1

Additional context
Add any other context about the problem here.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added
@ghost ghost added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Mar 26, 2021
@weidongxu-microsoft weidongxu-microsoft added the Azure.Core azure-core label Mar 26, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Mar 26, 2021
@weidongxu-microsoft
Copy link
Member Author

@anuchandy @jianghaolu for awareness.

@weidongxu-microsoft
Copy link
Member Author

weidongxu-microsoft commented May 26, 2021

Another case found:

@JsonFlatten ClassA
-- propertyA: final ClassB
---- propertyB: Map<>

The escaping of Map get interrupted by the "final" ClassB via https://github.com/Azure/azure-sdk-for-java/blob/azure-core_1.6.0/sdk/core/azure-core/src/main/java/com/azure/core/util/serializer/FlatteningSerializer.java#L121-L123

It could be solved by the "shallow" JsonFlatten (as it will not touch ClassB hence no need to escape propertyB) .However I am not sure what might be the impact of changing behavior from "deep" to "shallow".

@samvaity
Copy link
Member

Fixed with ##22591 to allow flattening of static and final variables.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Core azure-core
Projects
Status: Done
Development

No branches or pull requests

3 participants