diff --git a/flint-core/src/main/scala/org/opensearch/flint/core/http/handler/HttpAOSSResultPredicate.java b/flint-core/src/main/scala/org/opensearch/flint/core/http/handler/HttpAOSSResultPredicate.java index c5432eda9..8bfb05fa3 100644 --- a/flint-core/src/main/scala/org/opensearch/flint/core/http/handler/HttpAOSSResultPredicate.java +++ b/flint-core/src/main/scala/org/opensearch/flint/core/http/handler/HttpAOSSResultPredicate.java @@ -44,12 +44,14 @@ public boolean test(T result) throws Throwable { return false; } - // Buffer the entity to make it repeatable + // Buffer the entity to make it repeatable, so that this retry test does not consume the content stream, + // resulting in the request caller getting empty response BufferedHttpEntity bufferedEntity = new BufferedHttpEntity(entity); response.setEntity(bufferedEntity); try { String responseContent = EntityUtils.toString(bufferedEntity); + // Effectively restores the content stream of the response bufferedEntity.getContent().reset(); boolean isRetryable = responseContent.contains(RESOURCE_ALREADY_EXISTS_EXCEPTION_MESSAGE);