Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All lists to omit empty by default #5320

Merged
merged 1 commit into from
Jul 15, 2023
Merged

Conversation

shawkins
Copy link
Contributor

@shawkins shawkins commented Jul 9, 2023

Description

Closes #5262

There was only one real change to Fabric8DefaultRule, and one test updated to SerializationTest. Everything else is the update of the models - which was surprisingly quite extensive.

To add a little more the root casue of this behavior:

  • jsonschema2pojo defaults initializeCollections to true, so all lists in our built-in models already had an empty list (and maps) to being with
  • builders will preserve that empty list default, so users would need to call withField(null) to omit the collection.

So the alternative would be to set initializeCollections to false and have the Fabric8DefaultRule take over that responsibility and not initialize fields that are not set to omit empty. That of course could also potentially be seen as breaking behavior as users will be required to do null checks that they didn't have to do before.

Changing the getter to use Optional would be even more breaking, but could be considered as well.

@manusa @metacosm @rohanKanojia any thoughts about this? Whatever the decision, I'll add some appropriate change log entries.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • Code contributed by me aligns with current project license: Apache 2.0
  • I Added CHANGELOG entry regarding this change
  • I have implemented unit tests to cover my changes
  • I have added/updated the javadocs and other documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report
  • I tested my code in Kubernetes
  • I tested my code in OpenShift

@manusa
Copy link
Member

manusa commented Jul 10, 2023

It's my understanding that the current state of the PR is with the minimum set of breaking changes (i.e. collections are still initialized).

I'd delay further (more aggressive) changes to a subsequent PR

Copy link
Member

@manusa manusa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trusting your word that this PR only affects the @JsonInclude(JsonInclude.Include.NON_EMPTY) annotation, looks good to me.

@shawkins
Copy link
Contributor Author

It's my understanding that the current state of the PR is with the minimum set of breaking changes (i.e. collections are still initialized).

This change will be breaking for someone those who were relying upon empty collections

  • I'm not sure where in the standard resources this would make a difference between empty and missing for non-patch operations, our guess is that it does not.
  • Updated Patch with empty collections #4606 to more accurately describe where an empty collection would be used. With a json merge - an empty collection will cause the patch to remove the list. With a strategic merge if the list has a patchStrategy of atomic it will remove the list. Users relying upon that behavior wrt the built-in resource serializing with an empty collection will have a breaking change. json patches and SSA aren't affected.

Trusting your word that this PR only affects the @JsonInclude(JsonInclude.Include.NON_EMPTY) annotation, looks good to me.

Sure you can trust me. I also have some good deals on real estate :)

@manusa
Copy link
Member

manusa commented Jul 10, 2023

So I guess that we're more or less fine once we add the changelog + breaking note

@shawkins shawkins force-pushed the iss5262 branch 2 times, most recently from 4c6da3f to acb9213 Compare July 10, 2023 14:04
@shawkins
Copy link
Contributor Author

So I guess that we're more or less fine once we add the changelog + breaking note

Should be good now.

@manusa manusa self-assigned this Jul 14, 2023
@manusa manusa added this to the 6.8.0 milestone Jul 14, 2023
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@manusa manusa merged commit 72e427a into fabric8io:master Jul 15, 2023
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.

Determine if all built-in collections should omit empty
3 participants