public void setChangeStatus()

in commit-status-publisher-server/src/main/java/jetbrains/buildServer/commitPublisher/github/api/impl/GitHubApiImpl.java [218:262]


  public void setChangeStatus(@NotNull final String repoOwner,
                              @NotNull final String repoName,
                              @NotNull final String hash,
                              @NotNull final GitHubChangeState status,
                              @NotNull final String targetUrl,
                              @NotNull final String description,
                              @Nullable final String context) throws PublisherException, IOException {

    final String url = myUrls.getStatusUrl(repoOwner, repoName, hash);
    final String entity = myGson.toJson(new CommitStatus(status.getState(), targetUrl, description, context));

    final HttpMethod method = HttpMethod.POST;
    LoggerUtil.logRequest(Constants.GITHUB_PUBLISHER_ID, method, url, entity);

    final AtomicReference<Exception> exceptionRef = new AtomicReference<>();
    IOGuard.allowNetworkCall(() -> {
      myClient.post(
        url, authenticationCredentials(), defaultHeaders(),
        entity, ContentType.APPLICATION_JSON.getMimeType(), ContentType.APPLICATION_JSON.getCharset(),
        response -> {
        },
        response -> {
          String responseBody = logFailedResponse(method, url, entity, response);
          String githubError = parseErrorsFromResponse(responseBody);
          String additionalComment = githubError != null ? githubError : response.getStatusCode() == HttpStatus.SC_NOT_FOUND ? MSG_NOT_FOUND : MSG_PROXY_OR_PERMISSIONS;
          PublisherException ex = new PublisherException(getErrorMessage(response, additionalComment));
          if (RetryResponseProcessor.shouldRetryOnCode(response.getStatusCode())) {
            ex.setShouldRetry();
          }
          exceptionRef.set(ex);
        },
        e -> exceptionRef.set(e));
    });

    final Exception ex;
    if ((ex = exceptionRef.get()) != null) {
      if (ex instanceof PublisherException) {
        throw (PublisherException)ex;
      } else {
        PublisherException e = new PublisherException(ex.getMessage(), ex);
        RetryResponseProcessor.processNetworkException(ex, e);
        throw e;
      }
    }
  }