Hello,
when upgrading from spring boot 3.2.3 to 3.2.5 I'm getting following error:
java.lang.IllegalArgumentException: Mismatched number of generics specified for public class domain.core.repository.impl.EocsRepositoryFactoryBean<R extends org.springframework.data.jpa.repository.JpaRepository<T, java.lang.String>,T extends domain.core.domain.DistributedEntity>
at org.springframework.util.Assert.isTrue(Assert.java:129)
at org.springframework.core.ResolvableType.forClassWithGenerics(ResolvableType.java:1125)
at org.springframework.data.repository.config.RepositoryConfigurationDelegate.getRepositoryInterface(RepositoryConfigurationDelegate.java:367)
at org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn(RepositoryConfigurationDelegate.java:189)
at org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport.registerBeanDefinitions(RepositoryBeanDefinitionRegistrarSupport.java:94)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda$loadBeanDefinitionsFromRegistrars$1(ConfigurationClassBeanDefinitionReader.java:376)
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:375)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:148)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:120)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:428)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:289)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:349)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:118)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:788)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:606)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:334)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
It's probably caused by this change
We have custom factory bean
public class EocsRepositoryFactoryBean<
R extends JpaRepository<T, String>, T extends DistributedEntity> extends JpaRepositoryFactoryBean<R, T, String> {
The ResolvableType resolves just 2 type parameters while RepositoryConfigurationDelegate resolves 3 generics.
Maybe spring-data wasn't adapted to recent core change?
If you need a reproducible example, please let me know, but it might take some time.
Comment From: wilkinsona
The Framework change has just added a null guard around generics. For cases where it's non-null, I don't think it's changed when an IllegalArgumentException will be thrown. I think this is more likely to have been caused by the changes to Spring Data Commons made in https://github.com/spring-projects/spring-data-commons/commit/dd081d461435c292db356f976041ca01a94515a2 and https://github.com/spring-projects/spring-data-commons/commit/88011e6003e95bba721bb5680b049db0f9c9eaed.
Please open a Spring Data Commons issue so that they can investigate.