Forward port of issue #21487 to 2.4.x.

Comment From: wilkinsona

Re-opening due to flaky test. See https://github.com/spring-projects/spring-boot/issues/21487 for details.