Fix for #28615

Comment From: sbrannen

This has been merged into 5.3.x and main in 0ce9516aeff0f4bd8dd37770d161671e23a54304 and revised (with a test) in eeac150030db41ee41369381e00bab22f20a1e5e.

Thanks for making your first contribution to the Spring Framework! 👍