Inspectopedia Help

Throwable supplier never returns a value

Reports Supplier lambdas in Optional.orElseThrow() calls that throw an exception, instead of returning it.

Example:

optional.orElseThrow(() -> { throw new RuntimeException(); });

After the quick-fix is applied:

optional.orElseThrow(() -> new RuntimeException());

New in 2023.1

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Java, 241.16690

Last modified: 29 April 2024