From 6f32f7138db47f503974bd7ce71f32449289a3c7 Mon Sep 17 00:00:00 2001 From: Benjamin Trent Date: Sat, 6 Oct 2018 07:25:15 -0700 Subject: [PATCH] HLRC: Fixing bug when getting a missing pipeline (#34286) closes #34119 --- .../java/org/elasticsearch/client/IngestClient.java | 5 +++-- .../java/org/elasticsearch/client/IngestClientIT.java | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java index eb070759ed9..035d1fd26fb 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java @@ -29,6 +29,7 @@ import org.elasticsearch.action.ingest.SimulatePipelineResponse; import org.elasticsearch.action.support.master.AcknowledgedResponse; import java.io.IOException; +import java.util.Collections; import static java.util.Collections.emptySet; @@ -83,7 +84,7 @@ public final class IngestClient { */ public GetPipelineResponse getPipeline(GetPipelineRequest request, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity( request, IngestRequestConverters::getPipeline, options, - GetPipelineResponse::fromXContent, emptySet()); + GetPipelineResponse::fromXContent, Collections.singleton(404)); } /** @@ -96,7 +97,7 @@ public final class IngestClient { */ public void getPipelineAsync(GetPipelineRequest request, RequestOptions options, ActionListener listener) { restHighLevelClient.performRequestAsyncAndParseEntity( request, IngestRequestConverters::getPipeline, options, - GetPipelineResponse::fromXContent, listener, emptySet()); + GetPipelineResponse::fromXContent, listener, Collections.singleton(404)); } /** diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/IngestClientIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/IngestClientIT.java index 70685296192..84bf43ab019 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/IngestClientIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/IngestClientIT.java @@ -78,6 +78,16 @@ public class IngestClientIT extends ESRestHighLevelClientTestCase { assertEquals(expectedConfig.getConfigAsMap(), response.pipelines().get(0).getConfigAsMap()); } + public void testGetNonexistentPipeline() throws IOException { + String id = "nonexistent_pipeline_id"; + + GetPipelineRequest request = new GetPipelineRequest(id); + + GetPipelineResponse response = + execute(request, highLevelClient().ingest()::getPipeline, highLevelClient().ingest()::getPipelineAsync); + assertFalse(response.isFound()); + } + public void testDeletePipeline() throws IOException { String id = "some_pipeline_id"; {