Forward port of #12930
Comment From: jzheaux
Closed in https://github.com/spring-projects/spring-security/commit/c053f6f0c662e6b49edb7617498d9cf61e940fd5
Forward port of #12930
Comment From: jzheaux
Closed in https://github.com/spring-projects/spring-security/commit/c053f6f0c662e6b49edb7617498d9cf61e940fd5