// Check if the there is a ResultHandler left to execute if not just return the response
if (resultHandlers.hasNext()) {
// Special handling of FutureResponse
// See PROTOCOLS-37
if (response instanceof FutureResponse) {
final FutureResponseImpl futureResponse = new FutureResponseImpl();
((FutureResponse) response).addListener(new ResponseListener() {
public void onResponse(FutureResponse response) {
Response r = resultHandlers.next().onResponse(session, response, executionTime, cHandler);
// call the next ResultHandler
r = executeResultHandlers(session, r, executionTime, cHandler, resultHandlers);
// notify the FutureResponse that we are ready
futureResponse.setResponse(r);
}
});
// just return the new FutureResponse which will get notified once its ready
return futureResponse;