@Override public void call(Collection<String> item) throws Exception { if (items.size() > 1) { throw new CallbackRefusedException(); } items.add(item); } };
@Override public void call(final List<T> item) throws Exception { if (failed.get()) { throw new CallbackRefusedException(); } inFlight.incrementAndGet(); executor.submit(new ExecutorCallable<T>(out, item)); Future<Void> f; while ( (f = executor.poll()) != null ) { inFlight.decrementAndGet(); try { f.get(); } catch (ExecutionException e) { exceptions.addSuppressed(e.getCause()); if (failFast) { failed.set(true); exceptions.fillInStackTrace(); throw exceptions; } } } }