Forward port of #21293 to 2.4.x

Comment From: mbhave

Closed by https://github.com/spring-projects/spring-boot/commit/f96a2f2b8321f2321fbf9418c8018771370adb5a.