spring-projects / spring-projects/spring-data-rest
RepositoryRestMvcConfiguration sub classing attempt is failing because class DelegatingHandlerMapping made package private
@odrotbohm is already working on this.
Since Jul 25, 2022.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
While updating org.springframework.boot to 2.5.12, org.springframework.data:spring-data-rest-webmvc is updated to 3.5.10 as transitive dependency. In this version we found the problem. During bean creation we get the following exception:
"java.lang.IllegalAccessError: failed to access class org.springframework.data.rest.webmvc.config.DelegatingHandlerMapping...."
Digging into that we found class DelegatingHandlerMapping made package private (public access specifier removed form the class).
We are subclassing configuration class RepositoryRestMvcConfiguration (package org.springframework.data.rest.webmvc.config) to customize the configuration. Within that configuration class, one bean method restHandlerMapping() is returning DelegatingHandlerMapping object. When we are subclassing RepositoryRestMvcConfiguration then the bean method restHandlerMapping() becomes part of that subclass. And the package of the subclass is our local package which is different from the package org.springframework.data.rest.webmvc.config. Since DelegatingHandlerMapping is now package private, while creating bean restHandlerMapping() the IllegalAccessError is showing.
Despite the class documentation states that "To customize how the exporter works, subclass this and override..." (https://docs.spring.io/spring-data/rest/docs/current/api/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.html), that is no longer possible after DelegatingHandlerMapping has been made package private in commit d7f36b1 (https://github.com/spring-projects/spring-data-rest/commit/d7f36b118060157e208aa044eb5c1c038b2c1dc2).
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.