Skip to content
This repository was archived by the owner on Apr 20, 2021. It is now read-only.
This repository was archived by the owner on Apr 20, 2021. It is now read-only.

When deserialization fails, default instead of null value should be provided #1292

@tomas-knap

Description

@tomas-knap

Suppose that user:

  1. Serializes configuration for DPU template A
  2. Adjusts the DPU configuration class for DPU template A, loads it to odcs
  3. Tries to deserialize the previously stored configuration (with the previous version of the config class)
  4. As a result, all fields except of the new one should be deserialized properly. The new field which was not available in the previous configuration version is set to null. Why the default value is not used for such attribute?

Better behaviour: When there is an error when deserializing certain attribute, instead of using null and calling onDeserialize(), it would be better to set the default value and then call on Deserialize().

How to do it: When there is an error deserializing certain attribute, you may create new instance and try to get, via reflection, the default value for that attribute.

Motivation: onDeserialize() can serve in the same way, but it duplicated the effort of DPU developer, he has to initialize the attribute on two places which may introduce errors.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions