spring-projects / spring-projects/spring-data-rest
Order of RelProviders [DATAREST-904]
@odrotbohm is already working on this.
Since Dec 31, 2020.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Mathias D opened DATAREST-904 and commented
When trying to customize the rel name of a Resources collection we use @Relation to customize the item and collection rel of a type.
The expectation is that when the @Relation annotation is present this is used for the rel name. But the order of RelProviders is set up differently:
- RepositoryRelProvider - order = Ordered.LOWEST_PRECEDENCE + 10 = -2147483639
- AnnotationRelProvider - order = 100
- EvoInflectorRelProvider - order = Ordered.LOWEST_PRECEDENCE = 2147483647
So for entities and embeddables the AnnotationRelProvider would never be used because the RepositoryRelProvider always comes first.
We think that the AnnotationRelProvider should always be first in the list because you usually use it to override the defaults. We have a problem when using Resources of embeddable in a custom controller and the customization is not possible at all in this situation.
(!) the order of the RepositoryRelProvider is so high because Ordered.LOWEST_PRECEDENCE + 10 = Integer.MAX_VALUE + 10 and overflows to a small integer - is this a bug?
Affects: 2.5.2 (Hopper SR2), 2.5.3 (Hopper SR3)
2 votes, 2 watchers
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.