Skip to content

Commit

Permalink
Merge pull request #566 from amihaiemil/565
Browse files Browse the repository at this point in the history
#565 removed slash and logging
  • Loading branch information
amihaiemil authored Sep 27, 2020
2 parents 34b1787 + 16edf68 commit bc09a1b
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.selfxdsd.api.Comment;
import com.selfxdsd.api.Comments;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.json.Json;
import javax.json.JsonObject;
Expand All @@ -23,6 +25,13 @@
*/
final class GithubIssueComments implements Comments {

/**
* Logger.
*/
private static final Logger LOG = LoggerFactory.getLogger(
GithubIssueComments.class
);

/**
* Base Comments uri.
*/
Expand All @@ -48,19 +57,24 @@ final class GithubIssueComments implements Comments {
if(issueUriStr.endsWith("/")){
slash = "";
}
this.commentsUri = URI.create(issueUriStr + slash + "comments/");
this.commentsUri = URI.create(issueUriStr + slash + "comments");
this.resources = resources;
}

@Override
public Comment post(final String body) {
LOG.debug("Posting Comment to: [" + this.commentsUri + "].");
final Resource resource = resources.post(
this.commentsUri,
Json.createObjectBuilder().add("body", body).build()
);
if (resource.statusCode() == HttpURLConnection.HTTP_CREATED) {
return new GithubComment(resource.asJsonObject());
} else {
LOG.error(
"Expected status 201 CREATED, but got: ["
+ resource.statusCode() + "]."
);
throw new IllegalStateException(
"Github Issue Comment was not created. Status is "
+ resource.statusCode()
Expand Down

0 comments on commit bc09a1b

Please sign in to comment.