Source:
<code>public <U, V1> FutureCompletionStage<V1> thenCombineAsync( CompletionStage<? extends U> other, BiFunction<? super V, ? super U, ? extends V1> fn, Executor executor) { requireNonNull(other, "other"); requireNonNull(fn, "fn"); requireNonNull(executor, "executor"); Promise<V1> promise = executor().newPromise(); AtomicReference<Object> reference = new AtomicReference<>(Marker.EMPTY); abstract class CombineBiConsumer<T1, T2, T> implements BiConsumer<T, Throwable> { @SuppressWarnings("unchecked") @Override public void accept(T v, Throwable error) { if (error == null) { if (!reference.compareAndSet(Marker.EMPTY, v)) { Object rawValue = reference.get(); if (rawValue == Marker.ERROR) { return; } try { applyAndNotify0(promise, (T1) v, (T2) rawValue, fn); } catch (Throwable e) { <START> e.printStackTrace(); <END> } } } else { if (reference.getAndSet(Marker.ERROR) != Marker.ERROR) { promise.setFailure(error); } } } abstract void applyAndNotify0( Promise<V1> promise, T1 value1, T2 value2, BiFunction<? super V, ? super U, ? extends V1> fn); } whenCompleteAsync(new CombineBiConsumer<V, U, V>() { @Override void applyAndNotify0( Promise<V1> promise, V value1, U value2, BiFunction<? super V, ? super U, ? extends V1> fn) { applyAndNotify(promise, value1, value2, fn); } }, executor); other.whenCompleteAsync(new CombineBiConsumer<U, V, U>() { @Override void applyAndNotify0( Promise<V1> promise, U value1, V value2, BiFunction<? super V, ? super U, ? extends V1> fn) { applyAndNotify(promise, value2, value1, fn); } }, otherExecutor(executor)); return promise.asStage(); }</code><technical_language>I understand this is a ditch safety supposed get here, cleaner fail promise? returned stage hangs forever</technical_language>

Target:
public <U, V1> FutureCompletionStage<V1> thenCombineAsync( CompletionStage<? extends U> other, BiFunction<? super V, ? super U, ? extends V1> fn, Executor executor) { requireNonNull(other, "other"); requireNonNull(fn, "fn"); requireNonNull(executor, "executor"); Promise<V1> promise = executor().newPromise(); AtomicReference<Object> reference = new AtomicReference<>(Marker.EMPTY); abstract class CombineBiConsumer<T1, T2, T> implements BiConsumer<T, Throwable> { @SuppressWarnings("unchecked") @Override public void accept(T v, Throwable error) { if (error == null) { if (!reference.compareAndSet(Marker.EMPTY, v)) { Object rawValue = reference.get(); if (rawValue == Marker.ERROR) { return; } applyAndNotify0(promise, (T1) v, (T2) rawValue, fn); } } else { if (reference.getAndSet(Marker.ERROR) != Marker.ERROR) { promise.setFailure(error); } } } abstract void applyAndNotify0( Promise<V1> promise, T1 value1, T2 value2, BiFunction<? super V, ? super U, ? extends V1> fn); } whenCompleteAsync(new CombineBiConsumer<V, U, V>() { @Override void applyAndNotify0( Promise<V1> promise, V value1, U value2, BiFunction<? super V, ? super U, ? extends V1> fn) { applyAndNotify(promise, value1, value2, fn); } }, executor); other.whenCompleteAsync(new CombineBiConsumer<U, V, U>() { @Override void applyAndNotify0( Promise<V1> promise, U value1, V value2, BiFunction<? super V, ? super U, ? extends V1> fn) { applyAndNotify(promise, value2, value1, fn); } }, otherExecutor(executor)); return promise.asStage(); }