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

Comment From: mhalbritter

Closed in https://github.com/spring-projects/spring-boot/commit/2170941cf6e1dd5d8cd5102d630bc1be38cc5b5c