PromiseAggregator implements GenericFutureListener<F> { @SafeVarargs public final PromiseAggregator<V, F> add(Promise<V>... promises) { if (promises == null) { throw new NullPointerException("promises"); } if (promises.length == 0) { return this; } synchronized (this) { if (pendingPromises == null) { int size; if (promises.length > 1) { size = promises.length; } else { size = 2; } pendingPromises = new LinkedHashSet<Promise<V>>(size); } for (Promise<V> p : promises) { if (p == null) { continue; } pendingPromises.add(p); p.addListener(this); } } return this; } PromiseAggregator(Promise<Void> aggregatePromise, boolean failPending);  PromiseAggregator(Promise<Void> aggregatePromise); @SafeVarargs final PromiseAggregator<V, F> add(Promise<V>... promises); @Override synchronized void operationComplete(F future);  }
@Test public void testAddNullFuture() { @SuppressWarnings("unchecked") Promise<Void> p = mock(Promise.class); PromiseAggregator<Void, Future<Void>> a = new PromiseAggregator<Void, Future<Void>>(p); expectedException.expect(NullPointerException.class); a.add((Promise<Void>[]) null); }