This is a part of the fix to #20901. I've decided to move one method to Optional to make it null-safe.

Comment From: philwebb

@aivinog1 We've generally tried to keep out use of Optional to a minimum in the Spring Boot codebase. If can have some advantages, but it also has a habit of adding quite a lot of noise to the codebase.

There's an interesting talk by Stuart Marks that's worth a watch if you want some more background on where the JDK team recommend that it's used.

I think I'd prefer to keep the Optional change out of the fix for #20901. Thanks anyway.