WrappedCallback implements AsyncMethodCallback<T> { @Override public void onError(Exception exception) { try { logger.error("Releasing client on error", exception); releaseClient(exception instanceof TApplicationException); } catch (Throwable t) { logger.error("Error while running error callback", t); } try { underlying.onError(exception); } catch (Throwable t) { logger.error("Error while running client error callback", t); } } WrappedCallback(AsyncMethodCallback<T> underlying,
                         C client,
                         ClientPool<C> clientPool); @Override void onComplete(T response); @Override void onError(Exception exception);  }
@Test public void testOnError() throws Exception { WrappedCallback<AsyncSSLClient, echo_call> wcb = new WrappedCallback<>(callback, client, clientPool); Exception e = new Exception("foo bar"); wcb.onError(e); InOrder inOrder = inOrder(client, clientPool, callback); inOrder.verify(clientPool).release(client, false); inOrder.verify(callback).onError(e); verifyNoMoreInteractions(client, clientPool, callback); }