diff --git a/modules/ingest-common/src/yamlRestTest/resources/rest-api-spec/test/ingest/70_bulk.yml b/modules/ingest-common/src/yamlRestTest/resources/rest-api-spec/test/ingest/70_bulk.yml index 99d5be73bc00a..0c18cd8814bbf 100644 --- a/modules/ingest-common/src/yamlRestTest/resources/rest-api-spec/test/ingest/70_bulk.yml +++ b/modules/ingest-common/src/yamlRestTest/resources/rest-api-spec/test/ingest/70_bulk.yml @@ -237,6 +237,12 @@ teardown: _index: test_index _id: test_id2 - f1: v2 + - index: + _index: test_index + _id: test_id2 + pipeline: fake_pipeline + - f1: v2 - match: { items.0.index.executed_pipelines: ["pipeline1"] } - match: { items.1.index.executed_pipelines: [] } + - match: { items.2.index.executed_pipelines: null } diff --git a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java index 3de9526ef8fac..2f202dd21ad7c 100644 --- a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java +++ b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java @@ -183,7 +183,10 @@ public IndexRequest(@Nullable ShardId shardId, StreamInput in) throws IOExceptio if (in.getTransportVersion().onOrAfter(TransportVersions.PIPELINES_IN_BULK_RESPONSE_ADDED)) { this.listExecutedPipelines = in.readBoolean(); if (listExecutedPipelines) { - this.executedPipelines = new ArrayList<>(in.readCollectionAsList(StreamInput::readString)); + List possiblyImmutableExecutedPipelines = in.readOptionalCollectionAsList(StreamInput::readString); + this.executedPipelines = possiblyImmutableExecutedPipelines == null + ? null + : new ArrayList<>(possiblyImmutableExecutedPipelines); } } } @@ -749,7 +752,7 @@ private void writeBody(StreamOutput out) throws IOException { if (out.getTransportVersion().onOrAfter(TransportVersions.PIPELINES_IN_BULK_RESPONSE_ADDED)) { out.writeBoolean(listExecutedPipelines); if (listExecutedPipelines) { - out.writeCollection(executedPipelines, StreamOutput::writeString); + out.writeOptionalCollection(executedPipelines, StreamOutput::writeString); } } }