Imo we are doing this wrong. The API would be much more readible with static factory methods:
``` /** * {@link Consumer} that can throw checked exceptions. */ @FunctionalInterface public interface CheckedConsumer<T> { void checkedAccept(T t) throws Exception; static <T> Consumer<T> unchecked(CheckedConsumer<T> checkedConsumer) { return (t) -> { try { checkedConsumer.checkedAccept(t); } catch (Exception e) { ExceptionUtils.rethrow(e); } }; } } ``` This allows for: ``` CheckedConsumer.unchecked(isRecoveredJobRunning -> { ... }); ``` No casts are required. Also when interacting with the Java API, it does not matter what type of exception can be thrown. We do not need to generify the exception type in `ConsumerWithException`. [ Full content available at: https://github.com/apache/flink/pull/6678 ] This message was relayed via gitbox.apache.org for devnull@infra.apache.org