InitializeUserDetailsBeanManagerConfigurer warning names wrong logger (inner class vs. suggested outer class)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- authentication, security
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.
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).
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
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.
More from spring-projects/spring-security
-
status: waiting-for-triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
spring-projects/spring-security#19733 ·
-
status: waiting-for-triage type: enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
spring-projects/spring-security#19730 ·
-
status: waiting-for-triage type: bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
spring-projects/spring-security#19728 ·
-
status: waiting-for-triage type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
spring-projects/spring-security#19725 ·
-
in: build type: task
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
spring-projects/spring-security#19717 ·
All issues in spring-projects/spring-security
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100