Forward port of https://github.com/spring-projects/spring-security/pull/16050

Comment From: jzheaux

Close in 315aafd464958848274f9ee882e68e791f757f50