Skip to content

Commit

Permalink
[PRMT-4678] - Modified try-with-resources block to make unit test pass (
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadIqbalAD-NHS authored Mar 26, 2024
1 parent cb5f65a commit 0306a9a
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,19 @@ public StoreMessageResponseBody confirmMessageStored(ParsedMessage parsedMessage
.header("traceId", tracer.getTraceId())
.POST(jsonPayload).build();

try (var httpClient = HttpClient.newHttpClient()) {
var response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
HttpResponse<String> response;

if (response.statusCode() != 201) {
throw new HttpException(String.format("Unexpected response from EHR while checking if a message was stored: %d", response.statusCode()));
}
return parseResponse(response);
try (var httpClient = HttpClient.newHttpClient()) {
response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
} catch (Exception exception) {
throw new RuntimeException("Error encountered when uploading message to S3", exception);
}

if (response.statusCode() != 201) {
throw new HttpException(String.format("Unexpected response from EHR while checking if a message was stored: %d", response.statusCode()));
}

return parseResponse(response);
}

public void softDeleteEhrRecord(String nhsNumber) {
Expand Down

0 comments on commit 0306a9a

Please sign in to comment.