From ff9b28d806629c929cd61517437a627de77799ec Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Mon, 18 Apr 2016 15:04:23 -0400 Subject: [PATCH] Deprecate remaining readXYZ|writeXYZ methods --- .../common/io/stream/StreamInput.java | 16 +++++++++++++++ .../common/io/stream/StreamOutput.java | 20 ++++++++++++++++++- .../deletebyquery/DeleteByQueryRequest.java | 4 ++-- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java b/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java index 6516926edd1..887a30afb13 100644 --- a/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java +++ b/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java @@ -737,56 +737,72 @@ public abstract class StreamInput extends InputStream { /** * Reads a {@link QueryBuilder} from the current stream + * @deprecated prefer {@link #readNamedWriteable(Class)} passing {@link QueryBuilder}. */ + @Deprecated public QueryBuilder readQuery() throws IOException { return readNamedWriteable(QueryBuilder.class); } /** * Reads a {@link SuggestionBuilder} from the current stream + * @deprecated prefer {@link #readNamedWriteable(Class)} passing {@link SuggestionBuilder}. */ + @Deprecated public SuggestionBuilder readSuggestion() throws IOException { return readNamedWriteable(SuggestionBuilder.class); } /** * Reads a {@link SortBuilder} from the current stream + * @deprecated prefer {@link #readNamedWriteable(Class)} passing {@link SortBuilder}. */ + @Deprecated public SortBuilder readSortBuilder() throws IOException { return readNamedWriteable(SortBuilder.class); } /** * Reads a {@link org.elasticsearch.index.query.functionscore.ScoreFunctionBuilder} from the current stream + * @deprecated prefer {@link #readNamedWriteable(Class)} passing {@link ScoreFunctionBuilder}. */ + @Deprecated public ScoreFunctionBuilder readScoreFunction() throws IOException { return readNamedWriteable(ScoreFunctionBuilder.class); } /** * Reads a {@link SmoothingModel} from the current stream + * @deprecated prefer {@link #readNamedWriteable(Class)} passing {@link SmoothingModel}. */ + @Deprecated public SmoothingModel readPhraseSuggestionSmoothingModel() throws IOException { return readNamedWriteable(SmoothingModel.class); } /** * Reads a {@link Task.Status} from the current stream. + * @deprecated prefer {@link #readNamedWriteable(Class)} passing {@link Task.Status}. */ + @Deprecated public Task.Status readTaskStatus() throws IOException { return readNamedWriteable(Task.Status.class); } /** * Reads a {@link DocValueFormat} from the current stream. + * @deprecated prefer {@link #readNamedWriteable(Class)} passing {@link DocValueFormat}. */ + @Deprecated public DocValueFormat readValueFormat() throws IOException { return readNamedWriteable(DocValueFormat.class); } /** * Reads an {@link AllocationCommand} from the stream. + * @deprecated prefer {@link #readNamedWriteable(Class)} passing {@link AllocationCommand}. */ + @Deprecated public AllocationCommand readAllocationCommand() throws IOException { return readNamedWriteable(AllocationCommand.class); } diff --git a/core/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java b/core/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java index 02c55609b5b..1a0213ca094 100644 --- a/core/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java +++ b/core/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java @@ -702,28 +702,36 @@ public abstract class StreamOutput extends OutputStream { /** * Writes a {@link QueryBuilder} to the current stream + * @deprecated prefer {@link #writeNamedWriteable(NamedWriteable)} */ + @Deprecated public void writeQuery(QueryBuilder queryBuilder) throws IOException { writeNamedWriteable(queryBuilder); } /** * Writes a {@link ScoreFunctionBuilder} to the current stream + * @deprecated prefer {@link #writeNamedWriteable(NamedWriteable)} */ + @Deprecated public void writeScoreFunction(ScoreFunctionBuilder scoreFunctionBuilder) throws IOException { writeNamedWriteable(scoreFunctionBuilder); } /** * Writes the given {@link SmoothingModel} to the stream + * @deprecated prefer {@link #writeNamedWriteable(NamedWriteable)} */ + @Deprecated public void writePhraseSuggestionSmoothingModel(SmoothingModel smoothinModel) throws IOException { writeNamedWriteable(smoothinModel); } /** * Writes a {@link Task.Status} to the current stream. + * @deprecated prefer {@link #writeNamedWriteable(NamedWriteable)} */ + @Deprecated public void writeTaskStatus(Task.Status status) throws IOException { writeNamedWriteable(status); } @@ -767,26 +775,36 @@ public abstract class StreamOutput extends OutputStream { /** * Writes a {@link SuggestionBuilder} to the current stream + * @deprecated prefer {@link #writeNamedWriteable(NamedWriteable)} */ + @Deprecated public void writeSuggestion(SuggestionBuilder suggestion) throws IOException { writeNamedWriteable(suggestion); } /** * Writes a {@link SortBuilder} to the current stream + * @deprecated prefer {@link #writeNamedWriteable(NamedWriteable)} */ + @Deprecated public void writeSortBuilder(SortBuilder sort) throws IOException { writeNamedWriteable(sort); } - /** Writes a {@link DocValueFormat}. */ + /** + * Writes a {@link DocValueFormat}. + * @deprecated prefer {@link #writeNamedWriteable(NamedWriteable)} + */ + @Deprecated public void writeValueFormat(DocValueFormat format) throws IOException { writeNamedWriteable(format); } /** * Writes an {@link AllocationCommand} to the stream. + * @deprecated prefer {@link #writeNamedWriteable(NamedWriteable)} */ + @Deprecated public void writeAllocationCommand(AllocationCommand command) throws IOException { writeNamedWriteable(command); } diff --git a/plugins/delete-by-query/src/main/java/org/elasticsearch/action/deletebyquery/DeleteByQueryRequest.java b/plugins/delete-by-query/src/main/java/org/elasticsearch/action/deletebyquery/DeleteByQueryRequest.java index 7103cf1a4e0..145ef690dc3 100644 --- a/plugins/delete-by-query/src/main/java/org/elasticsearch/action/deletebyquery/DeleteByQueryRequest.java +++ b/plugins/delete-by-query/src/main/java/org/elasticsearch/action/deletebyquery/DeleteByQueryRequest.java @@ -208,7 +208,7 @@ public class DeleteByQueryRequest extends ActionRequest im indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); types = in.readStringArray(); - query = in.readQuery(); + query = in.readNamedWriteable(QueryBuilder.class); routing = in.readOptionalString(); size = in.readVInt(); if (in.readBoolean()) { @@ -225,7 +225,7 @@ public class DeleteByQueryRequest extends ActionRequest im out.writeStringArray(indices); indicesOptions.writeIndicesOptions(out); out.writeStringArray(types); - out.writeQuery(query); + out.writeNamedWriteable(query); out.writeOptionalString(routing); out.writeVInt(size); out.writeOptionalStreamable(scroll);