EnableMfaFiltersConfiguration.mfaBeanPostProcessor() should be static to avoid BeanPostProcessorChecker warning

オープン 初心者向け
#20,172 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 5 日以内に返信

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java, spring-boot

調査の方向性

ファクトリメソッド mfaBeanPostProcessor() は、パッケージ org.springframework.security.config.annotation.authorization の EnableMfaFiltersConfiguration で宣言されています。そのクラスを開き、返している内部クラス EnableMfaFiltersPostProcessor を確認してから、メソッドに static 修飾子を追加してください。メソッドが static になり、プロジェクトがコンパイルでき、既存の設定テストが起動ログに BeanPostProcessorChecker の警告を出さずに通れば完了です。

索引モデルが issue の本文から書いたものです。

説明

status: waiting-for-triage type: bug

Describe the bug

When @EnableMultiFactorAuthentication is used, the following warning is logged on every application startup:

WARN o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.authorization.EnableMfaFiltersConfiguration' of type [org.springframework.security.config.annotation.authorization.EnableMfaFiltersConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). The currently created BeanPostProcessor [mfaBeanPostProcessor] is declared through a non-static factory method on that class; consider declaring it as static instead.

EnableMfaFiltersConfiguration declares its BeanPostProcessor through a non-static @Bean method:

@Bean
BeanPostProcessor mfaBeanPostProcessor() {
    return new EnableMfaFiltersPostProcessor();
}

Because the factory method is non-static, the configuration class itself has to be instantiated early, while post-processors are still being registered. This triggers the warning. The same code is present on main, 7.1.x, and 7.0.x.

To Reproduce

  1. Create a Spring Boot application with Spring Security.
  2. Add @EnableMultiFactorAuthentication(authorities = {FactorGrantedAuthority.PASSWORD_AUTHORITY, FactorGrantedAuthority.OTT_AUTHORITY}) to a @Configuration class.
  3. Start the application and check the startup log.

Expected behavior

No BeanPostProcessorChecker warning is logged for Spring Security's own infrastructure configuration.

Suggested fix

Declare the factory method as static. EnableMfaFiltersPostProcessor is already a private static nested class and does not depend on the enclosing instance, so this should be a safe one-line change:

@Bean
static BeanPostProcessor mfaBeanPostProcessor() {
    return new EnableMfaFiltersPostProcessor();
}

Similar warnings were fixed this way in the past (e.g. gh-14751, gh-9845).

Environment

  • Spring Boot 4.2.0
  • Spring Security 7.2.0
  • Spring Framework 7.1.0
  • Java 25

Workaround

Suppress the logger:

logging:
  level:
    "[org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker]": error
主要言語
Java
スター
9.7k
フォーク
6.4k
平均マージ
5日 35分
マージ済み PR(30日)
19

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

spring-projects/spring-security のほかの issue

spring-projects/spring-security の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。