I have edited the gist to simplify it by using an simple Integer field 
instead of my own bucket object.

The corresponding output is now:

1. {"myInt":42,"myInteger":42}
2. myInt: 42, myInteger: 100
3. {"myInt":100,"myInteger":100}


On Tuesday, May 19, 2020 at 4:20:55 PM UTC+2, Clément Poulain wrote:
>
> Hi there,
>
> I'm experience a strange behavior when working with Jackson (v2.11.0) when 
> working with final fields.
> I have a POJO with some final fields, which I want to NOT be modifiable 
> during deserialization. It seems to be working as expected for primitive 
> type, but not for objects.
>
> I have created this gist to demonstrate the issue: 
> https://gist.github.com/Plonk42/82409983a684b44df6a564acc43a7d75
>
> The output of this gist is:
>
> 1. {"myField":42,"bucket":{"bucketField":42}}
> 2. myField: 42, bucketField:100
> 3. {"myField":100,"bucket":{"bucketField":100}}
>
> On line 1., the output is what we expect (both fields set to 42).
> Then I'm de-serializing a JSON payload representing a POJO, and we see the 
> first strange thing: "myField" is not modified (still 42) but "bucketField" 
> is modified (now 100).
> Then serializing again the resulting POJO, it gets even stranger: now both 
> fields are set to 100.
>
> Am I missing something??
>
> Thanks,
> Clément
>

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jackson-user/e183668f-4309-42a9-ad06-ca54848a40e2%40googlegroups.com.

Reply via email to