spring-projects / spring-projects/spring-security
InitializeUserDetailsBeanManagerConfigurer warning names wrong logger (inner class vs. suggested outer class)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
InitializeUserDetailsBeanManagerConfigurer logs this warning (added in #15538) when a global AuthenticationManager is built from an AuthenticationProvider bean while a UserDetailsService bean is also present:
If the current configuration is intentional, to turn off this warning, increase the logging level of 'org.springframework.security.config.annotation.authentication.configuration.InitializeUserDetailsBeanManagerConfigurer' to ERROR
Following this instruction does not actually suppress the warning.
The Log that emits the message is created inside the non-static inner class InitializeUserDetailsManagerConfigurer:
class InitializeUserDetailsBeanManagerConfigurer extends GlobalAuthenticationConfigurerAdapter {
class InitializeUserDetailsManagerConfigurer extends GlobalAuthenticationConfigurerAdapter {
private final Log logger = LogFactory.getLog(getClass());
getClass() here resolves to the inner class, so the real logger name is:
org.springframework.security.config.annotation.authentication.configuration.InitializeUserDetailsBeanManagerConfigurer$InitializeUserDetailsManagerConfigurer
— not the outer class name the message tells you to configure. Most logging backends (e.g. Log4j2) tokenize logger hierarchy on . only, so $ does not create a parent/child relationship. A logger override for exactly the name in the message therefore has no effect; only overriding the parent package, or the full Outer$Inner name, actually works. This is confusing since the message text never shows a $, so there's no visible hint that the suggested name is wrong.
Same bug class as spring-kafka#714 (fixed there): https://github.com/spring-projects/spring-kafka/issues/714
Suggested fix: create the Log on the outer class and reuse it in the inner class, so the logger name matches what the message says — or update the message to name the actual logger / suggest the parent package instead.
Repro
- Register a custom
AuthenticationProviderbean alongside aUserDetailsServicebean. - Start the app, observe the warning.
- Configure the exact logger name from the message to
ERROR(e.g. in Log4j2) — warning still appears after restart. - Configure
org.springframework.security.config.annotation.authentication.configuration(the parent package) toERRORinstead — warning is suppressed.
Version: 7.0.3 (also present on main).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in config/src/main/java/org/springframework/security/config/annotation/authentication/configuration/InitializeUserDetailsBeanManagerConfigurer.java, focusing on the logger declaration in the inner class and the warning text. Reproduce the warning with an AuthenticationProvider and UserDetailsService, then verify that configuring the logger name stated in the message suppresses it. Done means the emitted logger name matches the name documented by the warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authentication, security
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100