Forward port of issue #39518 to 3.2.x.

Comment From: izeye

https://github.com/spring-projects/spring-boot/pull/39518 has been declined, but this and https://github.com/spring-projects/spring-boot/issues/39520 don't seem to have been updated accordingly with their labels and miletone.

Comment From: wilkinsona

Thanks, @izeye.