The rule raises an issue when multiple early returns are used in a function returning a Void
. For example
public class CallableReproducer {
public void function(boolean a) throws Exception {
execute(new Callable<Void>() {
@Override
public Void call() throws Exception {
if (a) {
return null;
}
return null;
}
});
}
private <T> void execute(Callable<T> callable) throws Exception {
callable.call();
}
}
Void
is not instantiable, but even if it were, one would always return something like Void.NIL
. Runnable
is no alternative if the API used expects a Callable<T>
.