Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent log level in @Bean javadoc and ConfigurationClassEnhancer #25590

Closed
ttddyy opened this issue Aug 14, 2020 · 1 comment
Closed

Inconsistent log level in @Bean javadoc and ConfigurationClassEnhancer #25590

ttddyy opened this issue Aug 14, 2020 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: documentation A documentation task
Milestone

Comments

@ttddyy
Copy link
Contributor

ttddyy commented Aug 14, 2020

@Bean javadoc states when BFPP is defined with non-static method, it writes a WARN-level log message.

This works out in BFPP cases, as they are not typically referenced by other @bean methods.
As a reminder, a WARN-level log message will be issued for any non-static @bean methods having a return type assignable to BeanFactoryPostProcessor

The commit 9a43d2e (SPR-16946, #21485) updated the logging level in ConfigurationClassEnhancer and this message shows up as INFO log.

if (logger.isInfoEnabled() &&
    BeanFactoryPostProcessor.class.isAssignableFrom(beanMethod.getReturnType())) {
  logger.info(String.format("@Bean method %s.%s is non-static and returns an object " +
          "assignable to Spring's BeanFactoryPostProcessor interface. This will " +
          "result in a failure to process annotations such as @Autowired, " +
          "@Resource and @PostConstruct within the method's declaring " +
          "@Configuration class. Add the 'static' modifier to this method to avoid " +
          "these container lifecycle issues; see @Bean javadoc for complete details.",
      beanMethod.getDeclaringClass().getSimpleName(), beanMethod.getName()));
}

So, either javadoc or log level need to be updated to match actual description and behavior.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 14, 2020
@sbrannen sbrannen self-assigned this Aug 16, 2020
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: documentation A documentation task and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Aug 16, 2020
@sbrannen sbrannen added this to the 5.2.9 milestone Aug 16, 2020
@sbrannen
Copy link
Member

The Javadoc for @Bean is out of sync in this regard.

Thanks for pointing it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: documentation A documentation task
Projects
None yet
Development

No branches or pull requests

3 participants