[
https://issues.apache.org/jira/browse/AIRAVATA-3328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17113199#comment-17113199
]
Marcus Christie commented on AIRAVATA-3328:
-------------------------------------------
It occurs to me that this is problem for all Thrift data model fields that have
a default value. We know that it is a problem for *required* fields with
defaults because those fail validation when they aren't "set" by the Dozer
mapping. But the same thing would happen for non-required fields with defaults
if the default value matches the field value on the source object. In practice,
they may not be much of an issue, but the semantics around defaults seem to be
implemented in different ways in different languages (in Python I'm pretty sure
defaults are applied at the client even if they aren't set on the object). So
to be sure, I think the CustomBeanFactory should just set all fields with
default values, required and non-required.
> 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)