Liberalize StreamOutput#writeStringList (#37768)

In some cases we only have a string collection instead of a string list
that we want to serialize out. We have a convenience method for writing
a list of strings, but no such method for writing a collection of
strings. Yet, a list of strings is a collection of strings, so we can
simply liberalize StreamOutput#writeStringList to be more generous in
the collections that it accepts and write out collections of strings
too. On the other side, we do not have a convenience method for reading
a list of strings. This commit addresses both of these issues.
This commit is contained in:
Jason Tedor 2019-01-23 12:52:17 -05:00 committed by GitHub
parent 1c2ae9185c
commit 169cb38778
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 114 additions and 81 deletions

View File

@ -461,7 +461,7 @@ public class PutIndexTemplateRequest extends MasterNodeRequest<PutIndexTemplateR
name = in.readString();
if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) {
indexPatterns = in.readList(StreamInput::readString);
indexPatterns = in.readStringList();
} else {
indexPatterns = Collections.singletonList(in.readString());
}
@ -495,7 +495,7 @@ public class PutIndexTemplateRequest extends MasterNodeRequest<PutIndexTemplateR
out.writeString(cause);
out.writeString(name);
if (out.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) {
out.writeStringList(indexPatterns);
out.writeStringCollection(indexPatterns);
} else {
out.writeString(indexPatterns.size() > 0 ? indexPatterns.get(0) : "");
}

View File

@ -189,7 +189,7 @@ public class IndexTemplateMetaData extends AbstractDiffable<IndexTemplateMetaDat
Builder builder = new Builder(in.readString());
builder.order(in.readInt());
if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) {
builder.patterns(in.readList(StreamInput::readString));
builder.patterns(in.readStringList());
} else {
builder.patterns(Collections.singletonList(in.readString()));
}
@ -224,7 +224,7 @@ public class IndexTemplateMetaData extends AbstractDiffable<IndexTemplateMetaDat
out.writeString(name);
out.writeInt(order);
if (out.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) {
out.writeStringList(patterns);
out.writeStringCollection(patterns);
} else {
out.writeString(patterns.get(0));
}

View File

@ -946,12 +946,26 @@ public abstract class StreamInput extends InputStream {
}
/**
* Reads a list of objects
* Reads a list of objects. The list is expected to have been written using {@link StreamOutput#writeList(List)} or
* {@link StreamOutput#writeStreamableList(List)}.
*
* @return the list of objects
* @throws IOException if an I/O exception occurs reading the list
*/
public <T> List<T> readList(Writeable.Reader<T> reader) throws IOException {
public <T> List<T> readList(final Writeable.Reader<T> reader) throws IOException {
return readCollection(reader, ArrayList::new);
}
/**
* Reads a list of strings. The list is expected to have been written using {@link StreamOutput#writeStringCollection(Collection)}.
*
* @return the list of strings
* @throws IOException if an I/O exception occurs reading the list
*/
public List<String> readStringList() throws IOException {
return readList(StreamInput::readString);
}
/**
* Reads a set of objects
*/

View File

@ -1048,23 +1048,27 @@ public abstract class StreamOutput extends OutputStream {
}
/**
* Writes a collection of generic objects via a {@link Writer}
* Writes a collection of objects via a {@link Writer}.
*
* @param collection the collection of objects
* @throws IOException if an I/O exception occurs writing the collection
*/
public <T> void writeCollection(Collection<T> collection, Writer<T> writer) throws IOException {
public <T> void writeCollection(final Collection<T> collection, final Writer<T> writer) throws IOException {
writeVInt(collection.size());
for (T val: collection) {
for (final T val: collection) {
writer.write(this, val);
}
}
/**
* Writes a list of strings
* Writes a collection of a strings. The corresponding collection can be read from a stream input using
* {@link StreamInput#readList(Writeable.Reader)}.
*
* @param collection the collection of strings
* @throws IOException if an I/O exception occurs writing the collection
*/
public void writeStringList(List<String> list) throws IOException {
writeVInt(list.size());
for (String string: list) {
this.writeString(string);
}
public void writeStringCollection(final Collection<String> collection) throws IOException {
writeCollection(collection, StreamOutput::writeString);
}
/**

View File

@ -60,9 +60,9 @@ public final class RecoveryResponse extends TransportResponse {
RecoveryResponse(StreamInput in) throws IOException {
super(in);
phase1FileNames = in.readList(StreamInput::readString);
phase1FileNames = in.readStringList();
phase1FileSizes = in.readList(StreamInput::readVLong);
phase1ExistingFileNames = in.readList(StreamInput::readString);
phase1ExistingFileNames = in.readStringList();
phase1ExistingFileSizes = in.readList(StreamInput::readVLong);
phase1TotalSize = in.readVLong();
phase1ExistingTotalSize = in.readVLong();
@ -76,9 +76,9 @@ public final class RecoveryResponse extends TransportResponse {
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeStringList(phase1FileNames);
out.writeStringCollection(phase1FileNames);
out.writeCollection(phase1FileSizes, StreamOutput::writeVLong);
out.writeStringList(phase1ExistingFileNames);
out.writeStringCollection(phase1ExistingFileNames);
out.writeCollection(phase1ExistingFileSizes, StreamOutput::writeVLong);
out.writeVLong(phase1TotalSize);
out.writeVLong(phase1ExistingTotalSize);

View File

@ -103,7 +103,7 @@ public class PluginInfo implements Writeable, ToXContentObject {
}
this.classname = in.readString();
if (in.getVersion().onOrAfter(Version.V_6_2_0)) {
extendedPlugins = in.readList(StreamInput::readString);
extendedPlugins = in.readStringList();
} else {
extendedPlugins = Collections.emptyList();
}
@ -128,7 +128,7 @@ public class PluginInfo implements Writeable, ToXContentObject {
}
out.writeString(classname);
if (out.getVersion().onOrAfter(Version.V_6_2_0)) {
out.writeStringList(extendedPlugins);
out.writeStringCollection(extendedPlugins);
}
out.writeBoolean(hasNativeController);
if (out.getVersion().onOrAfter(Version.V_6_0_0_beta2) && out.getVersion().before(Version.V_6_3_0)) {

View File

@ -69,7 +69,7 @@ public class InternalComposite
public InternalComposite(StreamInput in) throws IOException {
super(in);
this.size = in.readVInt();
this.sourceNames = in.readList(StreamInput::readString);
this.sourceNames = in.readStringList();
this.formats = new ArrayList<>(sourceNames.size());
for (int i = 0; i < sourceNames.size(); i++) {
if (in.getVersion().onOrAfter(Version.V_6_3_0)) {
@ -90,7 +90,7 @@ public class InternalComposite
@Override
protected void doWriteTo(StreamOutput out) throws IOException {
out.writeVInt(size);
out.writeStringList(sourceNames);
out.writeStringCollection(sourceNames);
if (out.getVersion().onOrAfter(Version.V_6_3_0)) {
for (DocValueFormat format : formats) {
out.writeNamedWriteable(format);

View File

@ -243,7 +243,7 @@ public final class SearchSourceBuilder implements Writeable, ToXContentObject, R
}
}
if (in.readBoolean()) {
stats = in.readList(StreamInput::readString);
stats = in.readStringList();
}
suggestBuilder = in.readOptionalWriteable(SuggestBuilder::new);
terminateAfter = in.readVInt();
@ -311,7 +311,7 @@ public final class SearchSourceBuilder implements Writeable, ToXContentObject, R
boolean hasStats = stats != null;
out.writeBoolean(hasStats);
if (hasStats) {
out.writeStringList(stats);
out.writeStringCollection(stats);
}
out.writeOptionalWriteable(suggestBuilder);
out.writeVInt(terminateAfter);

View File

@ -20,6 +20,8 @@
package org.elasticsearch.common.io.stream;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.CheckedBiConsumer;
import org.elasticsearch.common.CheckedFunction;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.collect.Tuple;
@ -39,6 +41,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@ -293,15 +296,27 @@ public class StreamTests extends ESTestCase {
}
final int length = randomIntBetween(0, 16);
final Collection<FooBar> fooBars = new ArrayList<>(length);
runWriteReadCollectionTest(
() -> new FooBar(randomInt(), randomInt()), StreamOutput::writeCollection, in -> in.readList(FooBar::new));
}
public void testStringCollection() throws IOException {
runWriteReadCollectionTest(() -> randomUnicodeOfLength(16), StreamOutput::writeStringCollection, StreamInput::readStringList);
}
private <T> void runWriteReadCollectionTest(
final Supplier<T> supplier,
final CheckedBiConsumer<StreamOutput, Collection<T>, IOException> writer,
final CheckedFunction<StreamInput, Collection<T>, IOException> reader) throws IOException {
final int length = randomIntBetween(0, 10);
final Collection<T> collection = new ArrayList<>(length);
for (int i = 0; i < length; i++) {
fooBars.add(new FooBar(randomInt(), randomInt()));
collection.add(supplier.get());
}
try (BytesStreamOutput out = new BytesStreamOutput()) {
out.writeCollection(fooBars);
writer.accept(out, collection);
try (StreamInput in = out.bytes().streamInput()) {
assertThat(fooBars, equalTo(in.readList(FooBar::new)));
assertThat(collection, equalTo(reader.apply(in)));
}
}
}

View File

@ -273,7 +273,7 @@ public class AutoFollowMetadata extends AbstractNamedDiffable<MetaData.Custom> i
public AutoFollowPattern(StreamInput in) throws IOException {
remoteCluster = in.readString();
leaderIndexPatterns = in.readList(StreamInput::readString);
leaderIndexPatterns = in.readStringList();
followIndexPattern = in.readOptionalString();
maxReadRequestOperationCount = in.readOptionalVInt();
maxReadRequestSize = in.readOptionalWriteable(ByteSizeValue::new);
@ -350,7 +350,7 @@ public class AutoFollowMetadata extends AbstractNamedDiffable<MetaData.Custom> i
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(remoteCluster);
out.writeStringList(leaderIndexPatterns);
out.writeStringCollection(leaderIndexPatterns);
out.writeOptionalString(followIndexPattern);
out.writeOptionalVInt(maxReadRequestOperationCount);
out.writeOptionalWriteable(maxReadRequestSize);

View File

@ -275,7 +275,7 @@ public class PutAutoFollowPatternAction extends Action<AcknowledgedResponse> {
super(in);
name = in.readString();
remoteCluster = in.readString();
leaderIndexPatterns = in.readList(StreamInput::readString);
leaderIndexPatterns = in.readStringList();
followIndexNamePattern = in.readOptionalString();
maxReadRequestOperationCount = in.readOptionalVInt();
maxReadRequestSize = in.readOptionalWriteable(ByteSizeValue::new);
@ -294,7 +294,7 @@ public class PutAutoFollowPatternAction extends Action<AcknowledgedResponse> {
super.writeTo(out);
out.writeString(name);
out.writeString(remoteCluster);
out.writeStringList(leaderIndexPatterns);
out.writeStringCollection(leaderIndexPatterns);
out.writeOptionalString(followIndexNamePattern);
out.writeOptionalVInt(maxReadRequestOperationCount);
out.writeOptionalWriteable(maxReadRequestSize);

View File

@ -82,13 +82,13 @@ public class RemoveIndexLifecyclePolicyAction extends Action<RemoveIndexLifecycl
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
failedIndexes = in.readList(StreamInput::readString);
failedIndexes = in.readStringList();
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeStringList(failedIndexes);
out.writeStringCollection(failedIndexes);
}
@Override

View File

@ -327,7 +327,7 @@ public class FindFileStructureAction extends Action<FindFileStructureAction.Resp
timeout = in.readOptionalTimeValue();
charset = in.readOptionalString();
format = in.readBoolean() ? in.readEnum(FileStructure.Format.class) : null;
columnNames = in.readBoolean() ? in.readList(StreamInput::readString) : null;
columnNames = in.readBoolean() ? in.readStringList() : null;
hasHeaderRow = in.readOptionalBoolean();
delimiter = in.readBoolean() ? (char) in.readVInt() : null;
quote = in.readBoolean() ? (char) in.readVInt() : null;

View File

@ -84,7 +84,7 @@ public class GetJobsStatsAction extends Action<GetJobsStatsAction.Response> {
public Request(StreamInput in) throws IOException {
super(in);
jobId = in.readString();
expandedJobsIds = in.readList(StreamInput::readString);
expandedJobsIds = in.readStringList();
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
allowNoJobs = in.readBoolean();
}
@ -94,7 +94,7 @@ public class GetJobsStatsAction extends Action<GetJobsStatsAction.Response> {
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeString(jobId);
out.writeStringList(expandedJobsIds);
out.writeStringCollection(expandedJobsIds);
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
out.writeBoolean(allowNoJobs);
}

View File

@ -197,7 +197,7 @@ public class StartDatafeedAction extends Action<AcknowledgedResponse> {
timeout = TimeValue.timeValueMillis(in.readVLong());
if (in.getVersion().onOrAfter(Version.V_6_6_0)) {
jobId = in.readOptionalString();
datafeedIndices = in.readList(StreamInput::readString);
datafeedIndices = in.readStringList();
}
}
@ -274,7 +274,7 @@ public class StartDatafeedAction extends Action<AcknowledgedResponse> {
out.writeVLong(timeout.millis());
if (out.getVersion().onOrAfter(Version.V_6_6_0)) {
out.writeOptionalString(jobId);
out.writeStringList(datafeedIndices);
out.writeStringCollection(datafeedIndices);
}
}

View File

@ -246,14 +246,14 @@ public class DatafeedConfig extends AbstractDiffable<DatafeedConfig> implements
this.queryDelay = in.readOptionalTimeValue();
this.frequency = in.readOptionalTimeValue();
if (in.readBoolean()) {
this.indices = Collections.unmodifiableList(in.readList(StreamInput::readString));
this.indices = Collections.unmodifiableList(in.readStringList());
} else {
this.indices = null;
}
// This consumes the list of types if there was one.
if (in.getVersion().before(Version.V_7_0_0)) {
if (in.readBoolean()) {
in.readList(StreamInput::readString);
in.readStringList();
}
}
if (in.getVersion().before(Version.V_6_6_0)) {
@ -408,7 +408,7 @@ public class DatafeedConfig extends AbstractDiffable<DatafeedConfig> implements
out.writeOptionalTimeValue(frequency);
if (indices != null) {
out.writeBoolean(true);
out.writeStringList(indices);
out.writeStringCollection(indices);
} else {
out.writeBoolean(false);
}
@ -416,7 +416,7 @@ public class DatafeedConfig extends AbstractDiffable<DatafeedConfig> implements
// An empty list is expected
if (out.getVersion().before(Version.V_7_0_0)) {
out.writeBoolean(true);
out.writeStringList(Collections.emptyList());
out.writeStringCollection(Collections.emptyList());
}
if (out.getVersion().before(Version.V_6_6_0)) {
out.writeNamedWriteable(getParsedQuery());

View File

@ -107,14 +107,14 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
this.queryDelay = in.readOptionalTimeValue();
this.frequency = in.readOptionalTimeValue();
if (in.readBoolean()) {
this.indices = in.readList(StreamInput::readString);
this.indices = in.readStringList();
} else {
this.indices = null;
}
// This consumes the list of types if there was one.
if (in.getVersion().before(Version.V_7_0_0)) {
if (in.readBoolean()) {
in.readList(StreamInput::readString);
in.readStringList();
}
}
this.query = in.readOptionalNamedWriteable(QueryBuilder.class);
@ -148,7 +148,7 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
out.writeOptionalTimeValue(frequency);
if (indices != null) {
out.writeBoolean(true);
out.writeStringList(indices);
out.writeStringCollection(indices);
} else {
out.writeBoolean(false);
}
@ -156,7 +156,7 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
// An empty list is expected
if (out.getVersion().before(Version.V_7_0_0)) {
out.writeBoolean(true);
out.writeStringList(Collections.emptyList());
out.writeStringCollection(Collections.emptyList());
}
out.writeOptionalNamedWriteable(query);
out.writeOptionalWriteable(aggregations);

View File

@ -206,20 +206,20 @@ public class FileStructure implements ToXContentObject, Writeable {
format = in.readEnum(Format.class);
multilineStartPattern = in.readOptionalString();
excludeLinesPattern = in.readOptionalString();
columnNames = in.readBoolean() ? Collections.unmodifiableList(in.readList(StreamInput::readString)) : null;
columnNames = in.readBoolean() ? Collections.unmodifiableList(in.readStringList()) : null;
hasHeaderRow = in.readOptionalBoolean();
delimiter = in.readBoolean() ? (char) in.readVInt() : null;
quote = in.readBoolean() ? (char) in.readVInt() : null;
shouldTrimFields = in.readOptionalBoolean();
grokPattern = in.readOptionalString();
jodaTimestampFormats = in.readBoolean() ? Collections.unmodifiableList(in.readList(StreamInput::readString)) : null;
javaTimestampFormats = in.readBoolean() ? Collections.unmodifiableList(in.readList(StreamInput::readString)) : null;
jodaTimestampFormats = in.readBoolean() ? Collections.unmodifiableList(in.readStringList()) : null;
javaTimestampFormats = in.readBoolean() ? Collections.unmodifiableList(in.readStringList()) : null;
timestampField = in.readOptionalString();
needClientTimezone = in.readBoolean();
mappings = Collections.unmodifiableSortedMap(new TreeMap<>(in.readMap()));
ingestPipeline = in.readBoolean() ? Collections.unmodifiableMap(in.readMap()) : null;
fieldStats = Collections.unmodifiableSortedMap(new TreeMap<>(in.readMap(StreamInput::readString, FieldStats::new)));
explanation = Collections.unmodifiableList(in.readList(StreamInput::readString));
explanation = Collections.unmodifiableList(in.readStringList());
}
@Override

View File

@ -125,7 +125,7 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
public AnalysisConfig(StreamInput in) throws IOException {
bucketSpan = in.readTimeValue();
categorizationFieldName = in.readOptionalString();
categorizationFilters = in.readBoolean() ? Collections.unmodifiableList(in.readList(StreamInput::readString)) : null;
categorizationFilters = in.readBoolean() ? Collections.unmodifiableList(in.readStringList()) : null;
if (in.getVersion().onOrAfter(Version.V_6_2_0)) {
categorizationAnalyzerConfig = in.readOptionalWriteable(CategorizationAnalyzerConfig::new);
} else {
@ -134,7 +134,7 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
latency = in.readOptionalTimeValue();
summaryCountFieldName = in.readOptionalString();
detectors = Collections.unmodifiableList(in.readList(Detector::new));
influencers = Collections.unmodifiableList(in.readList(StreamInput::readString));
influencers = Collections.unmodifiableList(in.readStringList());
multivariateByFields = in.readOptionalBoolean();
}
@ -145,7 +145,7 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
out.writeOptionalString(categorizationFieldName);
if (categorizationFilters != null) {
out.writeBoolean(true);
out.writeStringList(categorizationFilters);
out.writeStringCollection(categorizationFilters);
} else {
out.writeBoolean(false);
}
@ -155,7 +155,7 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
out.writeOptionalTimeValue(latency);
out.writeOptionalString(summaryCountFieldName);
out.writeList(detectors);
out.writeStringList(influencers);
out.writeStringCollection(influencers);
out.writeOptionalBoolean(multivariateByFields);
}

View File

@ -187,7 +187,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
jobType = in.readString();
jobVersion = in.readBoolean() ? Version.readVersion(in) : null;
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
groups = Collections.unmodifiableList(in.readList(StreamInput::readString));
groups = Collections.unmodifiableList(in.readStringList());
} else {
groups = Collections.emptyList();
}
@ -444,7 +444,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
out.writeBoolean(false);
}
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
out.writeStringList(groups);
out.writeStringCollection(groups);
}
out.writeOptionalString(description);
out.writeVLong(createTime.getTime());
@ -671,7 +671,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
jobType = in.readString();
jobVersion = in.readBoolean() ? Version.readVersion(in) : null;
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
groups = in.readList(StreamInput::readString);
groups = in.readStringList();
} else {
groups = Collections.emptyList();
}
@ -856,7 +856,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
out.writeBoolean(false);
}
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
out.writeStringList(groups);
out.writeStringCollection(groups);
}
out.writeOptionalString(description);
if (createTime != null) {

View File

@ -125,7 +125,7 @@ public class JobUpdate implements Writeable, ToXContentObject {
modelSnapshotRetentionDays = in.readOptionalLong();
resultsRetentionDays = in.readOptionalLong();
if (in.readBoolean()) {
categorizationFilters = in.readList(StreamInput::readString);
categorizationFilters = in.readStringList();
} else {
categorizationFilters = null;
}
@ -172,7 +172,7 @@ public class JobUpdate implements Writeable, ToXContentObject {
out.writeOptionalLong(resultsRetentionDays);
out.writeBoolean(categorizationFilters != null);
if (categorizationFilters != null) {
out.writeStringList(categorizationFilters);
out.writeStringCollection(categorizationFilters);
}
out.writeMap(customSettings);
out.writeOptionalString(modelSnapshotId);

View File

@ -139,7 +139,7 @@ public class Bucket implements ToXContentObject, Writeable {
in.readList(Bucket::readOldPerPartitionNormalization);
}
if (in.getVersion().onOrAfter(Version.V_6_2_0)) {
scheduledEvents = in.readList(StreamInput::readString);
scheduledEvents = in.readStringList();
if (scheduledEvents.isEmpty()) {
scheduledEvents = Collections.emptyList();
}
@ -165,7 +165,7 @@ public class Bucket implements ToXContentObject, Writeable {
out.writeList(Collections.emptyList());
}
if (out.getVersion().onOrAfter(Version.V_6_2_0)) {
out.writeStringList(scheduledEvents);
out.writeStringCollection(scheduledEvents);
}
}

View File

@ -77,7 +77,7 @@ public class CategoryDefinition implements ToXContentObject, Writeable {
terms = in.readString();
regex = in.readString();
maxMatchingLength = in.readLong();
examples = new TreeSet<>(in.readList(StreamInput::readString));
examples = new TreeSet<>(in.readStringList());
if (in.getVersion().onOrAfter(Version.V_6_4_0)) {
grokPattern = in.readOptionalString();
}
@ -90,7 +90,7 @@ public class CategoryDefinition implements ToXContentObject, Writeable {
out.writeString(terms);
out.writeString(regex);
out.writeLong(maxMatchingLength);
out.writeStringList(new ArrayList<>(examples));
out.writeStringCollection(examples);
if (out.getVersion().onOrAfter(Version.V_6_4_0)) {
out.writeOptionalString(grokPattern);
}

View File

@ -124,7 +124,7 @@ public class ForecastRequestStats implements ToXContentObject, Writeable {
forecastId = in.readString();
recordCount = in.readLong();
if (in.readBoolean()) {
messages = in.readList(StreamInput::readString);
messages = in.readStringList();
} else {
messages = null;
}
@ -147,7 +147,7 @@ public class ForecastRequestStats implements ToXContentObject, Writeable {
out.writeLong(recordCount);
if (messages != null) {
out.writeBoolean(true);
out.writeStringList(messages);
out.writeStringCollection(messages);
} else {
out.writeBoolean(false);
}

View File

@ -86,7 +86,7 @@ public class MetricConfig implements Writeable, ToXContentObject {
MetricConfig(final StreamInput in) throws IOException {
field = in.readString();
metrics = in.readList(StreamInput::readString);
metrics = in.readStringList();
}
/**
@ -144,7 +144,7 @@ public class MetricConfig implements Writeable, ToXContentObject {
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(field);
out.writeStringList(metrics);
out.writeStringCollection(metrics);
}
@Override

View File

@ -49,12 +49,12 @@ public final class PutPrivilegesResponse extends ActionResponse implements ToXCo
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeMap(created, StreamOutput::writeString, StreamOutput::writeStringList);
out.writeMap(created, StreamOutput::writeString, StreamOutput::writeStringCollection);
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
this.created = Collections.unmodifiableMap(in.readMap(StreamInput::readString, si -> si.readList(StreamInput::readString)));
this.created = Collections.unmodifiableMap(in.readMap(StreamInput::readString, StreamInput::readStringList));
}
}

View File

@ -125,7 +125,7 @@ public class PutRoleMappingRequest extends ActionRequest
super.readFrom(in);
this.name = in.readString();
this.enabled = in.readBoolean();
this.roles = in.readList(StreamInput::readString);
this.roles = in.readStringList();
this.rules = ExpressionParser.readExpression(in);
this.metadata = in.readMap();
this.refreshPolicy = RefreshPolicy.readFrom(in);
@ -136,7 +136,7 @@ public class PutRoleMappingRequest extends ActionRequest
super.writeTo(out);
out.writeString(name);
out.writeBoolean(enabled);
out.writeStringList(roles);
out.writeStringCollection(roles);
ExpressionParser.writeExpression(rules, out);
out.writeMap(metadata);
refreshPolicy.writeTo(out);

View File

@ -49,8 +49,8 @@ public class TokensInvalidationResult implements ToXContentObject, Writeable {
}
public TokensInvalidationResult(StreamInput in) throws IOException {
this.invalidatedTokens = in.readList(StreamInput::readString);
this.previouslyInvalidatedTokens = in.readList(StreamInput::readString);
this.invalidatedTokens = in.readStringList();
this.previouslyInvalidatedTokens = in.readStringList();
this.errors = in.readList(StreamInput::readException);
this.attemptCount = in.readVInt();
}
@ -97,8 +97,8 @@ public class TokensInvalidationResult implements ToXContentObject, Writeable {
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeStringList(invalidatedTokens);
out.writeStringList(previouslyInvalidatedTokens);
out.writeStringCollection(invalidatedTokens);
out.writeStringCollection(previouslyInvalidatedTokens);
out.writeCollection(errors, StreamOutput::writeException);
out.writeVInt(attemptCount);
}

View File

@ -78,7 +78,7 @@ public class ExpressionRoleMapping implements ToXContentObject, Writeable {
public ExpressionRoleMapping(StreamInput in) throws IOException {
this.name = in.readString();
this.enabled = in.readBoolean();
this.roles = in.readList(StreamInput::readString);
this.roles = in.readStringList();
this.expression = ExpressionParser.readExpression(in);
this.metadata = in.readMap();
}
@ -87,7 +87,7 @@ public class ExpressionRoleMapping implements ToXContentObject, Writeable {
public void writeTo(StreamOutput out) throws IOException {
out.writeString(name);
out.writeBoolean(enabled);
out.writeStringList(roles);
out.writeStringCollection(roles);
ExpressionParser.writeExpression(expression, out);
out.writeMap(metadata);
}