Description
POJOs are being generated with initialized collections by default. This causes properties not set in the workflow to be unmarshaled to empty collections.
For instance, given the following JSON:
{
"id": "helloworld",
"annotations": ["hello", "world"]
}
getAnnotations()
should return a collection with two objects. This is working as expected.
Given the followin JSON:
{
"id": "helloworld",
"annotations": []
}
getAnnotations()
should return an empty collection. This is also working as expected.
Given the followin JSON:
{
"id": "helloworld"
}
getAnnotations()
should return null
, but currently it's returning an empty collection. Here's the problem.
This is a problem because there are properties that aren't required, but when present, they should not be empty.
Translating this to Java:
Value | Valid |
---|---|
null |
Yes |
empty | No |
not empty | Yes |
To fix this behavior, we just need to set initializeCollections to false
in pom.xml.
But, this change can break compatibility, since methods that today never return null
might return null
after the change, which may cause NullPointerExceptions
to users.
So, what do you guys think? Can I submit a PR to fix this issue?