Skip to content

Commit c047997

Browse files
authored
Merge pull request #531 from gcornacchia/develop
Ignoring 409 errors in second attempt of creating api access
2 parents 18aceb7 + a7df120 commit c047997

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAPIAccessAdapter.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,14 @@ public void createAPIAccess(APIAccess apiAccess, AbstractEntity parentEntity, Ty
253253
response = httpResponse.getResponseBody();
254254
statusCode = httpResponse.getStatusCode();
255255
if (statusCode < 200 || statusCode > 299) {
256-
LOG.error("Error creating/updating API Access: {} Response-Code: {} Response Body: {}", apiAccess, statusCode, response);
257-
throw new AppException("Error creating/updating API Access. Response-Code: " + statusCode, ErrorCode.API_MANAGER_COMMUNICATION);
256+
//even in second attempt we have to ignore 409 error (resource already exists)
257+
if (statusCode == 409 && response.contains("resource already exists")) {
258+
LOG.info("Unexpected response while creating/updating API Access: {} Response-Code: {} Response Body: {} Ignoring this error.", apiAccess, statusCode, response);
259+
return;
260+
} else {
261+
LOG.error("Error creating/updating API Access: {} Response-Code: {} Response Body: {}", apiAccess, statusCode, response);
262+
throw new AppException("Error creating/updating API Access. Response-Code: " + statusCode, ErrorCode.API_MANAGER_COMMUNICATION);
263+
}
258264
} else {
259265
LOG.info("Successfully created API-Access on retry. Received Status-Code: {}", statusCode);
260266
}

0 commit comments

Comments
 (0)