Skip to content

@Configurable BeanCurrentlyInCreationException thrown when not using DEBUG logging [SPR-5996] #10664

@spring-projects-issues

Description

@spring-projects-issues

Stefan Schmidt opened SPR-5996 and commented

Currently a BeanCreationException is thrown if the log level is not set to DEBUG (as per code snippet below). However, the exception should never be thrown if beanFactory.isCurrentlyInCreation is true. It should log the message when in DEBUG mode, otherwise do nothing.

This issue was caused by a change made to address #10422 in Spring Framework 3.0.0.M4 committed in revision 1327.

Current code in BeanConfigurerSupport (line 152 - 162):

if (rootCause instanceof BeanCurrentlyInCreationException) {
BeanCreationException bce = (BeanCreationException) rootCause;
if (logger.isDebugEnabled() && this.beanFactory.isCurrentlyInCreation(bce.getBeanName())) {
logger.debug("Failed to create target bean '" + bce.getBeanName() +
"' while configuring object of type [" + beanInstance.getClass().getName() +
"] - probably due to a circular reference. This is a common startup situation " +
"and usually not fatal. Proceeding without injection. Original exception: " + ex);
return;
}
}
throw ex;

This should be changed to:

if (rootCause instanceof BeanCurrentlyInCreationException) {
BeanCreationException bce = (BeanCreationException) rootCause;
if (this.beanFactory.isCurrentlyInCreation(bce.getBeanName())) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to create target bean '" + bce.getBeanName() +
"' while configuring object of type [" + beanInstance.getClass().getName() +
"] - probably due to a circular reference. This is a common startup situation " +
"and usually not fatal. Proceeding without injection. Original exception: " + ex);
}
return;
}
}
throw ex;


No further details from SPR-5996

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions