From ff76b0af8bbfe8e67476b1bc82142b2c5f1c0962 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Mon, 22 Jul 2019 17:20:21 +0900 Subject: [PATCH] Copy field names in stored fields context We have to copy the field names otherwise we either have a handle of a list that a caller might mutate or we might mutate when they aren't expecting it, or worse, a handle of a list that is not mutable (and we end up mutating the list). Relates #44665 --- .../org/elasticsearch/search/fetch/StoredFieldsContext.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/search/fetch/StoredFieldsContext.java b/server/src/main/java/org/elasticsearch/search/fetch/StoredFieldsContext.java index 8cb175ae156..9ac90806aa4 100644 --- a/server/src/main/java/org/elasticsearch/search/fetch/StoredFieldsContext.java +++ b/server/src/main/java/org/elasticsearch/search/fetch/StoredFieldsContext.java @@ -67,7 +67,7 @@ public class StoredFieldsContext implements Writeable { public StoredFieldsContext(StreamInput in) throws IOException { this.fetchFields = in.readBoolean(); if (fetchFields) { - this.fieldNames = (List) in.readGenericValue(); + this.fieldNames = new ArrayList<>((List) in.readGenericValue()); } else { this.fieldNames = null; }