Skip to content

Conversation

rob-bygrave
Copy link
Contributor

@rob-bygrave rob-bygrave commented Mar 19, 2025

The JAXB collections don't have setters but instead lazy initialise collections on getter methods, the generated code uses .addAll() which doesn't support the case when NULL is returned (vs empty collection).

Fix is to add a nullToEmpty() helper method for this case (JAXB style collections).

Fix to generated code adds the Types.nullToEmpty() like:

case "tags": 
  _$myJaxbType.getTags().addAll(Types.nullToEmpty(listStringJsonAdapter.fromJson(reader)));
  break;

The JAXB collections don't have setters but instead lazy initialise collections on getter methods, the generated code uses <getter>.addAll() which doesn't support the case when NULL is returned (vs empty collection).

Fix is to add a nullToEmpty() helper method for this case (JAXB style collections).
@rob-bygrave rob-bygrave requested a review from SentryMan March 19, 2025 03:33
@rob-bygrave rob-bygrave self-assigned this Mar 19, 2025
@rob-bygrave rob-bygrave merged commit e8a65cb into main Mar 19, 2025
9 checks passed
@rob-bygrave rob-bygrave deleted the feature/fix-null-jaxb-collections branch March 19, 2025 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants