Skip to content

Conversation

MatKuhr
Copy link
Member

@MatKuhr MatKuhr commented Aug 20, 2024

Context

This fixes a bug that would cause HTTP connections to stay open in case the destination service returns an error with payload. Which is the case for e.g. 404 responses.

Definition of Done

  • Functionality scope stated & covered
  • Tests cover the scope above
  • Error handling created / updated & covered by the tests above
  • Documentation updated
  • Release notes updated

@MatKuhr MatKuhr marked this pull request as ready for review August 22, 2024 18:11
@MatKuhr MatKuhr added please merge Request to merge a pull request please review Request to review a pull request labels Aug 22, 2024
Try<String> maybeBody = Try.of(() -> HttpEntityUtil.getResponseBody(response));
String logMessage = "Destination service returned HTTP status %s (%s)";
if( maybeBody.isFailure() ) {
final var ex =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(used var for better formatting)

requestUri));
}
Try<String> maybeBody = Try.of(() -> HttpEntityUtil.getResponseBody(response));
String logMessage = "Destination service returned HTTP status %s (%s)";
Copy link
Contributor

@newtork newtork Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Comment)
I'm not a fan of the dynamic string construction for log- and exception-messages. I know the format string %s is different from the log string template {} but I'm not sure the solution is the "best" practice yet.
The dynamic construction makes the code below complicated and during troubleshooting, we have to think twice, how a messages maps a corresponding piece of code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, I felt this was a tradeoff between complex code vs. code duplication. Maybe at some point we switch to a more high-level HTTP client, where we don't have to re-implement this response handling every time 😄

@newtork newtork merged commit 3168bbb into main Aug 26, 2024
14 checks passed
@newtork newtork deleted the fix/destination-service-error-handling branch August 26, 2024 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
please merge Request to merge a pull request please review Request to review a pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants