code: @Override
    public void processResponse(CloseableHttpResponse response) throws IOException, UnexpectedResponseException {
      if (getLog().isDebugEnabled()) {
        getLog().debug("Received response " + ToStringBuilder.reflectionToString(response, ToStringStyle.SHORT_PREFIX_STYLE));
      }
  
      int statusCode = response.getStatusLine().getStatusCode();
      if (statusCode == 401 || statusCode == 403) {
        getLog().info("Reacquiring access token.");
        accessToken = null;
        onConnect(oauthEndPoint);
        throw new RuntimeException("Access denied. Access token has been reacquired and retry may solve the problem. "
                                   + ToStringBuilder.reflectionToString(response, ToStringStyle.SHORT_PREFIX_STYLE));
  
      }
      if (batchSize > 1) {
        processBatchRequestResponse(response);
        numRecordsWritten += batchRecords.get().size();
        batchRecords = Optional.absent();
      } else {
        processSingleRequestResponse(response);
        numRecordsWritten++;
      }
    }
docs: Make it fail (throw exception) if status code is greater or equal to 400 except,
  the status code is 400 and error code is duplicate value, regard it as success(do not throw exception).
  
  If status code is 401 or 403, re-acquire access token before make it fail -- retry will take care of rest.
  
  {@inheritDoc}
  @see org.apache.gobblin.writer.http.HttpWriter#processResponse(org.apache.http.HttpResponse)