Skip to content

BeanNotOfRequiredTypeException (NullBean instead of null) when calling ApplicationContext.getBean(name, type) [SPR-16342] #20889

Closed
@spring-projects-issues

Description

@spring-projects-issues

Stefan Mueller opened SPR-16342 and commented

#20582 and #20711 fixed a similar bug. The problem still exists if calling ctx.getBean(name, type) for a null-bean which in older Spring versions (pre 5) returned null and now throws a org.springframework.beans.factory.BeanNotOfRequiredTypeException.

Can be reproduced by adding the following to spring-framework-issues

assertNotNull(ctx.getBean("bean1", IDummy.class)); // Works
assertNull(ctx.getBean("bean4", IDummy.class)); // Throws a BeanNotOfRequiredTypeException

Affects: 5.0.2

Issue Links:

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently apply

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions