Skip to content

Commit

Permalink
Debug logging for jira client
Browse files Browse the repository at this point in the history
  • Loading branch information
avarsava committed Apr 17, 2024
1 parent 71f8d41 commit 6675539
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
2 changes: 2 additions & 0 deletions changes/fix_jira-logging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Additional server logging for jira errors

Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public void labels(Set<String> labels) {
public ActionState perform(
ActionServices services, Duration lastGeneratedByOlive, boolean isOliveLive) {
if (connection == null) {
System.err.println("JIRA Connection for " + issueUrl + " is null.");
return ActionState.FAILED;
}
final var current = connection.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public ActionState perform(
.orElse(false)) {
bestMatch.accept(issue);
if (!connection.transition(issue, Stream::anyMatch, comment)) {
System.err.println("Unable to transition issue " + issue.getKey());
System.err.println("Connection: " + connection);
if (connection != null)
System.err.println("Connection has closedStatuses: " + connection.closedStatuses());
return ActionState.FAILED;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,16 +444,20 @@ boolean transition(
authenticationHeader.ifPresent(
header -> commentRequestBuilder.header("Authorization", header));

return CLIENT
.send(
commentRequestBuilder
.header("Content-Type", "application/json")
.POST(BodyPublishers.ofString(MAPPER.writeValueAsString(updateComment)))
.build(),
BodyHandlers.discarding())
.statusCode()
/ 100
== 2;
var result =
CLIENT.send(
commentRequestBuilder
.header("Content-Type", "application/json")
.POST(BodyPublishers.ofString(MAPPER.writeValueAsString(updateComment)))
.build(),
BodyHandlers.ofString());
boolean isGood = result.statusCode() / 100 == 2;
if (!isGood) {
System.err.println(
"Unable to transition issue " + issue.getKey() + " using any of " + transitions);
System.err.println("Got " + result.body());
}
return isGood;
}
}
return false;
Expand Down

0 comments on commit 6675539

Please sign in to comment.