basic-lib/src/main/java/com/streamsets/pipeline/stage/destination/http/HttpClientTarget.java
private void processResponse(
      Record record,
      Future<Response> responseFuture,
      long maxRequestCompletionSecs,
      boolean failOn403
  ) throws StageException {
    Response response;
    try {
      response = responseFuture.get(maxRequestCompletionSecs, TimeUnit.SECONDS);
      String responseBody = "";
      if (response.hasEntity()) {
        responseBody = response.readEntity(String.class);
      }
      response.close();
      if (conf.client.useOAuth2 && response.getStatus() == 403 && !failOn403) {
        HttpStageUtil.getNewOAuth2Token(conf.client.oauth2, httpClientCommon.getClient());
      } else if (response.getStatus() < 200 || response.getStatus() >= 300) {
        throw new OnRecordErrorException(
            record,
            Errors.HTTP_40,
            response.getStatus(),
            response.getStatusInfo().getReasonPhrase() + " " + responseBody
        );
      } else {
        if (conf.responseConf.sendResponseToOrigin) {
          if (ResponseType.SUCCESS_RECORDS.equals(conf.responseConf.responseType)) {
            getContext().toSourceResponse(record);
          } else {
            getContext().toSourceResponse(createResponseRecord(responseBody));
          }
        }
      }
    } catch (InterruptedException | ExecutionException e) {
      LOG.error(Errors.HTTP_41.getMessage(), e.toString(), e);
      throw new OnRecordErrorException(record, Errors.HTTP_41, e.toString());
    } catch (TimeoutException e) {
      LOG.error("HTTP request future timed out", e.toString(), e);
      throw new OnRecordErrorException(record, Errors.HTTP_41, e.toString());
    }
  }
private void processResponse(
      Record record,
      Future<Response> responseFuture,
      long maxRequestCompletionSecs,
      boolean failOn403
  ) throws StageException {
    Response response;
    try {
      response = responseFuture.get(maxRequestCompletionSecs, TimeUnit.SECONDS);
      String responseBody = "";
      if (response.hasEntity()) {
        responseBody = response.readEntity(String.class);
      }
      response.close();
      if (conf.client.useOAuth2 && response.getStatus() == 403 && !failOn403) {
        HttpStageUtil.getNewOAuth2Token(conf.client.oauth2, httpClientCommon.getClient());
      } else if (response.getStatus() < 200 || response.getStatus() >= 300) {
        throw new OnRecordErrorException(
            record,
            Errors.HTTP_40,
            response.getStatus(),
            response.getStatusInfo().getReasonPhrase() + " " + responseBody
        );
      } else {
        if (conf.responseConf.sendResponseToOrigin) {
          if (ResponseType.SUCCESS_RECORDS.equals(conf.responseConf.responseType)) {
            getContext().toSourceResponse(record);
          } else {
            getContext().toSourceResponse(createResponseRecord(responseBody));
          }
        }
      }
    } catch (InterruptedException | ExecutionException e) {
      LOG.error(Errors.HTTP_41.getMessage(), e.toString(), e);
      throw new OnRecordErrorException(record, Errors.HTTP_41, e.toString());
    } catch (TimeoutException e) {
      LOG.error("HTTP request future timed out", e.toString(), e);
      throw new OnRecordErrorException(record, Errors.HTTP_41, e.toString());
    }
  }
Waits for the Jersey client to complete an asynchronous request, checks the response code
and continues to parse the response if it is deemed ok.

@param record the current record to set in context for any expression evaluation
@param responseFuture the async HTTP request future
@param maxRequestCompletionSecs maximum time to wait for request completion (start to finish)
@throws StageException if the request fails, times out, or cannot be parsed