Skip to content

Commit

Permalink
Merge pull request #531 from gcornacchia/develop
Browse files Browse the repository at this point in the history
Ignoring 409 errors in second attempt of creating api access
  • Loading branch information
rathnapandi authored Jan 8, 2025
2 parents 18aceb7 + a7df120 commit c047997
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,14 @@ public void createAPIAccess(APIAccess apiAccess, AbstractEntity parentEntity, Ty
response = httpResponse.getResponseBody();
statusCode = httpResponse.getStatusCode();
if (statusCode < 200 || statusCode > 299) {
LOG.error("Error creating/updating API Access: {} Response-Code: {} Response Body: {}", apiAccess, statusCode, response);
throw new AppException("Error creating/updating API Access. Response-Code: " + statusCode, ErrorCode.API_MANAGER_COMMUNICATION);
//even in second attempt we have to ignore 409 error (resource already exists)
if (statusCode == 409 && response.contains("resource already exists")) {
LOG.info("Unexpected response while creating/updating API Access: {} Response-Code: {} Response Body: {} Ignoring this error.", apiAccess, statusCode, response);
return;
} else {
LOG.error("Error creating/updating API Access: {} Response-Code: {} Response Body: {}", apiAccess, statusCode, response);
throw new AppException("Error creating/updating API Access. Response-Code: " + statusCode, ErrorCode.API_MANAGER_COMMUNICATION);
}
} else {
LOG.info("Successfully created API-Access on retry. Received Status-Code: {}", statusCode);
}
Expand Down

0 comments on commit c047997

Please sign in to comment.