Closed
Description
David J. M. Karlsen opened SPR-14097 and commented
Relates to #16761
When beans are instrumented with interceptors it doesn't resolve them properly.
E.g. this returns me 0 candidates:
ResolvableType resolvableType = ResolvableType.forClassWithGenerics( StgBusinessService.class, function.getClass() );
while this works
private <T extends Function> StgBusinessService<T> findBusinessService( T t ) {
Map<String,StgBusinessService> services = applicationContext.getBeansOfType( StgBusinessService.class );
ParameterizedType parameterizedType = TypeUtils.parameterize( StgBusinessService.class, function.getClass() );
return services
.values()
.stream()
.filter( service -> ArrayUtils.contains( AopUtils.getTargetClass( service ).getGenericInterfaces(), parameterizedType ) )
.findFirst()
.orElseThrow( () -> new IllegalStateException( "No handler for function type: " + function ) );
}
The 1st variant passes in my simple unit-test where there are no application of AOP, while it doesn't when loading the full-blown application which adds AOP.
Affects: 4.2.5
Issue Links:
- Add generics / parameterized type support to ListableBeanFactory getBeanNamesForType/getBeansOfType methods [SPR-12147] #16761 Add generics / parameterized type support to ListableBeanFactory getBeanNamesForType/getBeansOfType methods
- getBeanNamesForType(ResolvableType) doesn't work for raw singleton instance from @Bean method with generic return type [SPR-17524] #22056 getBeanNamesForType(ResolvableType) doesn't work for raw singleton instance from
@Bean
method with generic return type - ListableBeanFactory#getBeanNamesForType(ResolvableType) fails to return generic @Bean methods [SPR-14118] #18690 ListableBeanFactory#getBeanNamesForType(ResolvableType) fails to return generic
@Bean
methods - getBeanNamesForType(ResolvableType) doesn't match generic factory method return type for yet-to-be-created bean [SPR-15011] #19578 getBeanNamesForType(ResolvableType) doesn't match generic factory method return type for yet-to-be-created bean