@Override
    public void operationComplete(F future) throws Exception {
        InternalLogger internalLogger = logNotifyFailure ? logger : null;
        if (future.isSuccess()) {
            V result = future.get();
            for (Promise<? super V> p: promises) {
                PromiseNotificationUtil.trySuccess(p, result, internalLogger);
            }
        } else if (future.isCancelled()) {
            for (Promise<? super V> p: promises) {
                PromiseNotificationUtil.tryCancel(p, internalLogger);
            }
        } else {
            Throwable cause = future.cause();
            for (Promise<? super V> p: promises) {
                PromiseNotificationUtil.tryFailure(p, cause, internalLogger);
            }
        }
    }
@Test
    public void testListenerFailure() throws Exception {
        @SuppressWarnings("unchecked")
        Promise<Void> p1 = mock(Promise.class);
        @SuppressWarnings("unchecked")
        Promise<Void> p2 = mock(Promise.class);

        @SuppressWarnings("unchecked")
        PromiseNotifier<Void, Future<Void>> notifier =
                new PromiseNotifier<Void, Future<Void>>(p1, p2);

        @SuppressWarnings("unchecked")
        Future<Void> future = mock(Future.class);
        Throwable t = mock(Throwable.class);
        when(future.isSuccess()).thenReturn(false);
        when(future.isCancelled()).thenReturn(false);
        when(future.cause()).thenReturn(t);
        when(p1.tryFailure(t)).thenReturn(true);
        when(p2.tryFailure(t)).thenReturn(true);

        notifier.operationComplete(future);
        verify(p1).tryFailure(t);
        verify(p2).tryFailure(t);
    }