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