@Test(expected=BatchingCallbackExecutionException.class) public void testSingleExceptionFails() throws Exception { ExecutorService executor = Executors.newSingleThreadExecutor(); try { Callback<List<String>> out = new Callback<List<String>>() { @Override public void call(List<String> item) throws Exception { Thread.sleep(10); throw new IllegalStateException("boom!"); } }; BatchingCallback<String> batcher = BatchingCallback.batchInto(2, executor, out, true); batcher.call("a"); batcher.close(); } finally { executor.shutdownNow(); } } }