Skip to content

Commit

Permalink
Add logging for failures in RFS OpenSearch put
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Kurait <[email protected]>
  • Loading branch information
AndreKurait committed Jun 26, 2024
1 parent ab5915b commit a978c0a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions RFS/src/main/java/com/rfs/common/OpenSearchClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,15 @@ private Optional<ObjectNode> createObjectIdempotent(String objectPath, ObjectNod
.block();

if (response.code == HttpURLConnection.HTTP_NOT_FOUND) {
client.put(objectPath, settings.toString());
return Optional.of(settings);
}
response = client.put(objectPath, settings.toString());

Check warning on line 100 in RFS/src/main/java/com/rfs/common/OpenSearchClient.java

View check run for this annotation

Codecov / codecov/patch

RFS/src/main/java/com/rfs/common/OpenSearchClient.java#L100

Added line #L100 was not covered by tests
if (response.code == HttpURLConnection.HTTP_CREATED || response.code == HttpURLConnection.HTTP_OK) {
return Optional.of(settings);

Check warning on line 102 in RFS/src/main/java/com/rfs/common/OpenSearchClient.java

View check run for this annotation

Codecov / codecov/patch

RFS/src/main/java/com/rfs/common/OpenSearchClient.java#L102

Added line #L102 was not covered by tests
} else {
logger.error("Could not create object: " + objectPath + ". Response Code: " + response.code +

Check warning on line 104 in RFS/src/main/java/com/rfs/common/OpenSearchClient.java

View check run for this annotation

Codecov / codecov/patch

RFS/src/main/java/com/rfs/common/OpenSearchClient.java#L104

Added line #L104 was not covered by tests
", Response Message: " + response.message + ", Response Body: " + response.body);
return Optional.empty();

Check warning on line 106 in RFS/src/main/java/com/rfs/common/OpenSearchClient.java

View check run for this annotation

Codecov / codecov/patch

RFS/src/main/java/com/rfs/common/OpenSearchClient.java#L106

Added line #L106 was not covered by tests
}
}
// The only response code that can end up here is HTTP_OK, which means the object already existed
return Optional.empty();
}
Expand Down

0 comments on commit a978c0a

Please sign in to comment.