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

Comment From: bclozel

Closed with e01a23b