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
This commit is contained in:
Jason Tedor 2019-07-22 17:20:21 +09:00
parent b34ac66d96
commit ff76b0af8b
No known key found for this signature in database
GPG Key ID: FA89F05560F16BC5
1 changed files with 1 additions and 1 deletions

View File

@ -67,7 +67,7 @@ public class StoredFieldsContext implements Writeable {
public StoredFieldsContext(StreamInput in) throws IOException {
this.fetchFields = in.readBoolean();
if (fetchFields) {
this.fieldNames = (List<String>) in.readGenericValue();
this.fieldNames = new ArrayList<>((List<String>) in.readGenericValue());
} else {
this.fieldNames = null;
}