Forward port of issue https://github.com/spring-projects/spring-boot/issues/43989 to 3.5.x.

Comment From: bclozel

Closed with fc01b01