From a8b8a96036058a9ce50511d3736c5e05fc20444d Mon Sep 17 00:00:00 2001 From: Sooraj Sinha <81695996+soosinha@users.noreply.github.com> Date: Fri, 7 May 2021 20:03:16 +0530 Subject: [PATCH] Remove URL content from Reindex error response (#630) Signed-off-by: Sooraj Sinha --- .../index/reindex/remote/RemoteScrollableHitSource.java | 3 ++- .../index/reindex/remote/RemoteScrollableHitSourceTests.java | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/remote/RemoteScrollableHitSource.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/remote/RemoteScrollableHitSource.java index 17df6b1d4c5..369b5fe2ef5 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/remote/RemoteScrollableHitSource.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/remote/RemoteScrollableHitSource.java @@ -186,8 +186,9 @@ public class RemoteScrollableHitSource extends ScrollableHitSource { } if (xContentType == null) { try { + logger.debug("Response didn't include Content-Type: " + bodyMessage(response.getEntity())); throw new OpenSearchException( - "Response didn't include Content-Type: " + bodyMessage(response.getEntity())); + "Response didn't include supported Content-Type, remote is likely not an OpenSearch instance"); } catch (IOException e) { OpenSearchException ee = new OpenSearchException("Error extracting body from response"); ee.addSuppressed(e); diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/remote/RemoteScrollableHitSourceTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/remote/RemoteScrollableHitSourceTests.java index 25599d9af56..5bc92addae6 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/remote/RemoteScrollableHitSourceTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/remote/RemoteScrollableHitSourceTests.java @@ -94,7 +94,6 @@ import java.util.stream.Stream; import static org.opensearch.common.unit.TimeValue.timeValueMillis; import static org.opensearch.common.unit.TimeValue.timeValueMinutes; -import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.instanceOf; @@ -472,7 +471,7 @@ public class RemoteScrollableHitSourceTests extends OpenSearchTestCase { public void testNoContentTypeIsError() { RuntimeException e = expectListenerFailure(RuntimeException.class, (RejectAwareActionListener listener) -> sourceWithMockedRemoteCall(false, null, "main/0_20_5.json").lookupRemoteVersion(listener)); - assertThat(e.getMessage(), containsString("Response didn't include Content-Type: body={")); + assertEquals(e.getMessage(), "Response didn't include supported Content-Type, remote is likely not an OpenSearch instance"); } public void testInvalidJsonThinksRemoteIsNotES() throws IOException {