spring-projects / spring-data-rest

Simplifies building hypermedia-driven REST web services on top of Spring Data repositories
https://spring.io/projects/spring-data-rest
Apache License 2.0
921 stars 562 forks source link

RepositoryRestMvcConfiguration should use defaultMessageConverters in extendHandlerExceptionResolvers #2431

Open rajp33 opened 2 weeks ago

rajp33 commented 2 weeks ago

Right now the RepositoryRestMvcConfiguration uses the defaultMessageConverters property : https://github.com/spring-projects/spring-data-rest/blob/56c271dee118f713fd8dc0999828738a1c1abae8/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java#L776

which is lazily loaded to all beans matching type HttpMessageConverter https://github.com/spring-projects/spring-data-rest/blob/56c271dee118f713fd8dc0999828738a1c1abae8/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java#L291

However there is also a bean defined: https://github.com/spring-projects/spring-data-rest/blob/56c271dee118f713fd8dc0999828738a1c1abae8/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java#L798

that I think should be used instead. The property isn't necessary and circumvents application wide customization of the message converters present in the bean: https://github.com/spring-projects/spring-data-rest/blob/56c271dee118f713fd8dc0999828738a1c1abae8/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java#L828

rajp33 commented 2 weeks ago

Should be a very small PR, happy to submit if needed :)

rajp33 commented 1 week ago

@odrotbohm let me know what you think!