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

Arnold Robert Turdean updated JOHNZON-312:
------------------------------------------
    Description: 
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.
 

  was:
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":{
      "TUESDAY":[
        {
          "start":null, <---------------------
          "end":"08:00+03:00"
        }
      ],
      "MONDAY":[
        {
          "start":"07:00+03:00",
          "end":"08:00+03:00"
        }
      ]
    }
  },
  ...
}
{code}
 

 

, but because of the mentioned bug the result is:

 
{code:java}
{
...
  "caseDiscussionDailySchedule":{
    "schedule":{
      "TUESDAY":[
        {
          "start":null, <---------------------
          "end":"08:00+03:00"
        }
      ],
      "MONDAY":[
        {
          "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.


> 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)

Reply via email to