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

fix(model): Use SettableBeanProperty.Delegating for jackson delegation #6343

Merged
merged 4 commits into from
Sep 23, 2024

Conversation

fxshlein
Copy link
Contributor

@fxshlein fxshlein commented Sep 11, 2024

Description

Fixes: #6342

Changes the delegation in SettableBeanPropertyDelegate from a custom implementation to the standard way of implementing a delegating property in jackson. This way, if some jackson module overrides methods that are not delegated explicitely here, they will continue to work.

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

@fxshlein
Copy link
Contributor Author

Ironically, markAsIgnorable and isIgnorable are missing from the jackson delegation. This might mean it doesn't make sense to delegate these, but I've kept them here for now, since I didn’t want to break anything, especially because there are tests for these two.

Comment on lines 60 to 61
SettableBeanProperty secondDelegateMock = mock(SettableBeanProperty.class, RETURNS_DEEP_STUBS);
doReturn(secondDelegateMock).when(delegateMock).withValueDeserializer(any());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Jackson is being smart here, and they have a check whether the new delegate is the same as the old, so a separate one needs to be used to test this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left these tests here for now, since I think they are still useful for verifying that the jackson delegation works as expected. For example, without these, I would not have noticed that isIgnorable and markAsIgnorable are not delegated by jackson.

@manusa manusa self-assigned this Sep 18, 2024
fxshlein and others added 3 commits September 19, 2024 05:48
Changes the delegation in SettableBeanPropertyDelegate from
a custom implementation to the standard way of implementing
a delegating property in jackson. This way, if some jackson
module overrides methods that are not delegated explicitely
here, they will continue to work.

Fixes: fabric8io#6342
…eBeanProperty

Includes tests to ensure all methods are implemented in future
Jackson versions too.

Signed-off-by: Marc Nuri <[email protected]>
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.

LGTM, thx!

Copy link

sonarcloud bot commented Sep 20, 2024

@manusa manusa merged commit d881c0e into fabric8io:main Sep 23, 2024
21 checks passed
@manusa manusa modified the milestones: 7.0.0, 6.13.4 Sep 25, 2024
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.

UnmatchedFieldTypeModule prevents certain jackson features from working
3 participants