public void waitForResponse(int timeoutSec) throws Exception {
  if (futureResponse == null) {
    throw new CodedException(X_INTERNAL_ERROR,"Request uninitialized");
  }
  LOG.trace("waitForResponse()");
  try {
    HttpResponse response=futureResponse.get(timeoutSec,TimeUnit.SECONDS);
    handleResponse(response);
  }
 catch (  TimeoutException e) {
    cancelRequest();
    throw new CodedException(X_NETWORK_ERROR,"Connection timed out");
  }
catch (  Exception e) {
    handleFailure(e);
  }
 finally {
    futureResponse=null;
    PerformanceLogger.log(LOG,"waitForResponse() done");
  }
}

public void waitForResponse ( int timeoutSec ) throws Exception { if ( futureResponse == null ) { throw new CodedException ( X_INTERNAL_ERROR , "Request uninitialized" ) ; } LOG . trace ( "waitForResponse()" ) ; try { HttpResponse response = futureResponse . get ( timeoutSec , TimeUnit . SECONDS ) ; handleResponse ( response ) ; } catch ( TimeoutException e ) { cancelRequest ( ) ; throw new CodedException ( X_NETWORK_ERROR , "Connection timed out" ) ; } catch ( Exception e ) { handleFailure ( e ) ; } finally { futureResponse = null ; PerformanceLogger . log ( LOG , "waitForResponse() done" ) ; } }
will block until response becomes available in the future .
