Forward port of #14218

Comment From: marcusdacoregio

Closed via https://github.com/spring-projects/spring-security/commit/7c1e6f36c96e67ae246efab9aea747439a6b6ec4