Skip to content

rj-cam/beans-for-type

Repository files navigation

beans-for-type

BeanFactoryUtils.getBeanNamesForType(ResolvableType) change in behavior from Spring Boot 3.3.x (and earlier) top 3.4.x.

Code

Class Definitions

  1. AlphaRequest/BravoRequest/CharlieRequest extends Request
  2. CharlieSubRequest extends CharlieRequest
  3. AlphaProcessor implements Processor
  4. BravoProcessor implements Processor
  5. CharlieProcessor implements Processor
  6. CharlieSubProcessor implements Processor
  7. CharlieGenericProcessor implements Processor
  8. CharlieSubGenericProcessor implements Processor

Retrieving Beans of a Given Type with a Specific Generics Type

image

String[] beanNames = context.getBeanNamesForType(ResolvableType.forClassWithGenerics(Processor.class, CharlieRequest.class));

Translation: Give me all Processors implementations for CharlieRequest type.

3.3.x or Earlier Behavior

beanNames = [charlieGenericProcessor, charlieProcessor]

This is our expected behavior which our functionality is based on.

3.4.x Behavior

image

beanNames = [charlieGenericProcessor, charlieProcessor, charlieSubGenericProcessor]

It is now including CharlieSubGenericProcessor. CharlieRequest does not meet the extends CharlieSubRequest criteria. For some reason, it is matching super types as well.

This is actual behavior after upgrading and causing unexpected processors to run.

About

BeanFactoryUtils.beanNamesForType change in behavior

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages