Hey,

Note: this is on 4.0.0-RC1

I noticed with this commit https://github.com/spring-projects/spring-boot/commit/4ebf09ad12166cb25bef6de7a3532007a006cb37 the BootstrapContext::getOrElseThrow is now marked as @Nullable:

    <T, X extends Throwable> @Nullable T getOrElseThrow(Class<T> type, Supplier<? extends X> exceptionSupplier)
            throws X;

I'm not sure if this is intentional or not, but it does feel pretty unexpected from a user perspective. It's also not in the javadoc, which seems to also be conflicting on what exception is to be thrown:

     * @return the instance managed by the context
     * @throws X if the type has not been registered
     * @throws IllegalStateException if the type has not been registered

As a user, I expect a method named getOrElseThrow to either return the thing or throw, and not return null in any case.

Comment From: wilkinsona

The nullability looks correct to me as you can register a type with a supplier that produces null. There's a test for this:

https://github.com/spring-projects/spring-boot/blob/f11e3f38770a628189f88f8c4134dd44ccb32e55/core/spring-boot/src/test/java/org/springframework/boot/bootstrap/DefaultBootstrapContextTests.java#L239-L243

We should update the javadoc to clarify the behavior when a registered supplier produces null. The only time when an exception will be thrown or when the fallback supplier will be called is when isRegistered(Class) returns false.