Skip to content

Clarify when BootstrapContext get methods may return null rather than throwing an exception or calling the fallback supplier #47896

@tschut

Description

@tschut

Hey,

Note: this is on 4.0.0-RC1

I noticed with this commit 4ebf09a 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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions