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

Ensure that HalConfiguration MediaTypeConfigurationCustomizers are always run #291

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

vierbergenlars
Copy link
Member

cg:content & cg:relation links are not an array when there is only a single value.

This happens because spring-data-rest does not process MediaTypeConfigurationCustomizer, so it does not apply the configuration when pulling the HalConfiguration bean directly.
This leads to the configuration settings in HalConfiguration inconsistently being applied, depending on if a setting is used in spring-hateoas or spring-data-rest.

Always applying all customizers directly in a BeanPostProcessor ensures that the HalConfiguration bean itself has all the customizations directly baked-in,
and does not require all consumers to be aware of MediaTypeConfigurationCustomizer.

This does result in MediaTypeConfigurationCustomizers being applied twice where HalConfiguration is used in spring-hateoas,
but all usual configurations are idempotent anyways (e.g. adding configuration for a link relation, or setting the ObjectMapper customizer)

@vierbergenlars vierbergenlars requested a review from a team as a code owner November 18, 2024 08:59
Copy link
Contributor

@NielsCW NielsCW left a comment

Choose a reason for hiding this comment

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

There seems to be a failing test in AutomationsRestControllerTest.

@vierbergenlars
Copy link
Member Author

I noticed.
We need to see how we are going to tackle that, because the cg:entity relation can only be configured once to be either be single or a list.
The main endpoints really need it to be a list; the automation endpoint seems to use it as a pointer to a single item. Those usages are not compatible.

…ways run

spring-data-rest is not aware of the existence of MediaTypeConfigurationCustomizer, so it does not apply the configuration when pulling the HalConfiguration bean directly.
This leads to the configuration settings in HalConfiguration inconsistently being applied, depending on if a setting is used in spring-hateoas or spring-data-rest.

Always applying all customizers directly in a BeanPostProcessor ensures that the HalConfiguration bean itself has all the customizations directly baked-in,
and does not require all consumers to be aware of MediaTypeConfigurationCustomizer
@vierbergenlars vierbergenlars force-pushed the always-apply-mediatype-customizers branch from bdba3eb to 5a0d836 Compare November 25, 2024 10:46
@vierbergenlars vierbergenlars merged commit 7d21fc5 into main Nov 25, 2024
9 checks passed
@vierbergenlars vierbergenlars deleted the always-apply-mediatype-customizers branch November 25, 2024 11:08
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