You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@johnzon.apache.org by "Arnold Robert Turdean (Jira)" <ji...@apache.org> on 2020/05/19 22:03:00 UTC
[jira] [Closed] (JOHNZON-312) JsonPatch's add operation updates
unexpected fields
[ https://issues.apache.org/jira/browse/JOHNZON-312?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Arnold Robert Turdean closed JOHNZON-312.
-----------------------------------------
The fix works perfectly in 1.2.6, thank you!
> JsonPatch's add operation updates unexpected fields
> ---------------------------------------------------
>
> Key: JOHNZON-312
> URL: https://issues.apache.org/jira/browse/JOHNZON-312
> Project: Johnzon
> Issue Type: Bug
> Components: Core
> Affects Versions: 1.2.3, 1.2.5
> Reporter: Arnold Robert Turdean
> Priority: Critical
> Labels: easyfix, patch
> Fix For: 1.2.6
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> Recently we found an important bug with the Johnzon framework. It's easy to reproduce and the fix seems important. The add operation is not working 100% well for nested objects. (in my example for a map which contains a list in the value)
> Example:
> Data:
>
> {code:java}
> {
> ...
> "caseDiscussionDailySchedule":{
> "schedule":{
> "TUESDAY":[
> {
> "start":"07:00+03:00",
> "end":"08:00+03:00"
> }
> ],
> "MONDAY":[
> {
> "start":"07:00+03:00",
> "end":"08:00+03:00"
> }
> ]
> }
> },
> ...
> }
> {code}
>
>
> Operation:
>
> {code:java}
> [ {"op": "replace", "path": "/caseDiscussionDailySchedule/schedule/MONDAY/0/start", "value": null} ]
> {code}
>
>
> I expect that the result should be this:
>
> {code:java}
> {
> ...
> "caseDiscussionDailySchedule":{
> "schedule":{
> "MONDAY":[
> {
> "start":null, <---------------------
> "end":"08:00+03:00"
> }
> ],
> "TUESDAY":[
> {
> "start":"07:00+03:00",
> "end":"08:00+03:00"
> }
> ]
> }
> },
> ...
> }
> {code}
>
>
> , but because of the mentioned bug the result is:
>
> {code:java}
> {
> ...
> "caseDiscussionDailySchedule":{
> "schedule":{
> "MONDAY":[
> {
> "start":null, <---------------------
> "end":"08:00+03:00"
> }
> ],
> "TUESDAY":[
> {
> "start":null, <---------------------
> "end":"08:00+03:00"
> }
> ]
> }
> },
> ...
> }
> {code}
>
>
> It seems to me that the bug is in the *JsonPointerImpl's* *isPositionToAdd* method while it checks only the parent element's equivalence, instead of checking the whole path's equivalence.
> Could you fix somehow the mentioned problem ? It would be very important for us and I guess that for a lot of other people as well.
>
> Note: in the above example I reproduced the problem with a "replace" operation, but the bug is with the "add" operation. (while the replace makes a remove and then an add, the remove worked fine)
>
> Thank you so much,
> have a nice day.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)