Skip to content

Conversation

@Ogenbertrand
Copy link
Contributor

@Ogenbertrand Ogenbertrand commented Oct 21, 2025

Previos State: There are two different implementations for communicating with the external status list server:

  • The StatusListService uses Java's built-in HttpClient.
  • The StatusListProtocolMapper uses the Apache CloseableHttpClient.

The Problem: This creates code duplication, inconsistencies in error handling and configuration, and adds an unnecessary dependency.

Required Action: All HTTP logic should be centralized within the StatusListService. The StatusListProtocolMapper should be refactored to call methods on the StatusListService instead of making its own HTTP requests.

Closes: #26

Copy link
Collaborator

@mbunwe-victor mbunwe-victor left a comment

Choose a reason for hiding this comment

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

Hello @Ogenbertrand, I have added these few comments.
Could you take a look?

private final String authToken;
private final HttpClient httpClient;
private final CloseableHttpClient httpClient;
private final ObjectMapper objectMapper;
Copy link
Collaborator

Choose a reason for hiding this comment

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

CloseableHttpClient holds connection pools and threads that must be explicitly released. Not closing it causes resource leaks. Could you implement an AutoCloseable or add a cleanup method?

return HttpClients.custom()
.setDefaultRequestConfig(requestConfig)
.setRetryStrategy(retryStrategy)
.build();
Copy link
Collaborator

Choose a reason for hiding this comment

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

HTTP clients are expensive to create, and creating one per service instance is wasteful. You could consider using a shared HTTP client pool or a singleton pattern.

logger.warnf("[Attempt %d/%d] Failed to send status: %d %s",
execCount, maxRetries, response.getCode(), response.getReasonPhrase());
int status = response.getCode();
return execCount <= maxRetries && (status >= 500);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't you think this is going to retry all IOExceptions, including non-retryable ones. What if we only retry on transient failures?

});
} catch (IOException | URISyntaxException e) {
if (e.getCause() instanceof StatusListServerException) {
throw (StatusListServerException) e.getCause();
Copy link
Collaborator

Choose a reason for hiding this comment

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

The current changes wrap StatusListServerException inside an IOException and then manually unwrap it later. Doesn't this add unnecessary complexity and make the exception flow harder to follow?
What if we just throw StatusListServerException directly when the status code indicates a failure? This will simplify the try/catch logic.

@Ogenbertrand Ogenbertrand requested a review from hugoib October 24, 2025 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement HTTP retry strategy within the framework of the HTTP client library, not manually. For readability.

2 participants