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

Marcus Christie updated AIRAVATA-3328:
--------------------------------------
    Description: 
Thrift required fields can have a default value. This value is present in the 
generated models, but it is only serialized if the field has actually been set. 
The semantics on required fields with default values seems a little confusing.

This causes an issue with Dozer since it has logic to only copy fields when 
they differ. A field on an entity will only copy to a Thrift data model field 
when they have the same value. If the field on the entity has the default value 
of the Thrift field, then it won't copy and that field will not get serialized. 
This then causes a validation error in Thrift since the required field wasn't 
set.

This problem was initially discoverred in AIRAVATA-3268, see [this 
comment|https://issues.apache.org/jira/browse/AIRAVATA-3268?focusedCommentId=16978768&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16978768]
 and following.

I think, as noted in [this 
comment|https://issues.apache.org/jira/browse/AIRAVATA-3268?focusedCommentId=16979609&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16979609],
 that we can create a [Dozer Custom Bean 
Factory|https://dozermapper.github.io/gitbook/documentation/custombeanfactories.html]
 to fix this.

TODO
- [ ] Test that CustomBeanFactory does "set" required fields that have a 
default value
- [ ] Test that ObjectMapperSingleton maps required default fields 
appropriately and they have a value even if there is no corresponding field on 
the source object. Basically this tests that the ObjectMapperSingleton is 
correctly configured to use the CustomBeanFactory

  was:
Thrift required fields can have a default value. This value is present in the 
generated models, but it is only serialized if the field has actually been set. 
The semantics on required fields with default values seems a little confusing.

This causes an issue with Dozer since it has logic to only copy fields when 
they differ. A field on an entity will only copy to a Thrift data model field 
when they have the same value. If the field on the entity has the default value 
of the Thrift field, then it won't copy and that field will not get serialized. 
This then causes a validation error in Thrift since the required field wasn't 
set.

This problem was initially discoverred in AIRAVATA-3268, see [this 
comment|https://issues.apache.org/jira/browse/AIRAVATA-3268?focusedCommentId=16978768&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16978768]
 and following.

I think, as noted in [this 
comment|https://issues.apache.org/jira/browse/AIRAVATA-3268?focusedCommentId=16979609&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16979609],
 that we can create a [Dozer Custom Bean 
Factory|https://dozermapper.github.io/gitbook/documentation/custombeanfactories.html]
 to fix this.




> Fix Thrift/Dozer incompatibilty in Java 11
> ------------------------------------------
>
>                 Key: AIRAVATA-3328
>                 URL: https://issues.apache.org/jira/browse/AIRAVATA-3328
>             Project: Airavata
>          Issue Type: New Feature
>          Components: Registry API
>            Reporter: Marcus Christie
>            Assignee: Marcus Christie
>            Priority: Major
>
> Thrift required fields can have a default value. This value is present in the 
> generated models, but it is only serialized if the field has actually been 
> set. The semantics on required fields with default values seems a little 
> confusing.
> This causes an issue with Dozer since it has logic to only copy fields when 
> they differ. A field on an entity will only copy to a Thrift data model field 
> when they have the same value. If the field on the entity has the default 
> value of the Thrift field, then it won't copy and that field will not get 
> serialized. This then causes a validation error in Thrift since the required 
> field wasn't set.
> This problem was initially discoverred in AIRAVATA-3268, see [this 
> comment|https://issues.apache.org/jira/browse/AIRAVATA-3268?focusedCommentId=16978768&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16978768]
>  and following.
> I think, as noted in [this 
> comment|https://issues.apache.org/jira/browse/AIRAVATA-3268?focusedCommentId=16979609&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16979609],
>  that we can create a [Dozer Custom Bean 
> Factory|https://dozermapper.github.io/gitbook/documentation/custombeanfactories.html]
>  to fix this.
> TODO
> - [ ] Test that CustomBeanFactory does "set" required fields that have a 
> default value
> - [ ] Test that ObjectMapperSingleton maps required default fields 
> appropriately and they have a value even if there is no corresponding field 
> on the source object. Basically this tests that the ObjectMapperSingleton is 
> correctly configured to use the CustomBeanFactory



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to