Forward port of issue #25367 to 2.5.x.

Comment From: wilkinsona

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