diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RoundTripTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RoundTripTests.java index 901c4db006f..8210fc0aaca 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RoundTripTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RoundTripTests.java @@ -41,7 +41,7 @@ import static org.apache.lucene.util.TestUtil.randomSimpleString; import static org.elasticsearch.common.unit.TimeValue.parseTimeValue; /** - * Round trip tests for all Streamable things declared in this plugin. + * Round trip tests for all {@link Writeable} things declared in this plugin. */ public class RoundTripTests extends ESTestCase { public void testReindexRequest() throws IOException { diff --git a/server/src/main/java/org/elasticsearch/common/io/stream/Streamable.java b/server/src/main/java/org/elasticsearch/common/io/stream/Streamable.java deleted file mode 100644 index 626da516567..00000000000 --- a/server/src/main/java/org/elasticsearch/common/io/stream/Streamable.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.common.io.stream; - -import java.io.IOException; -import java.util.function.Supplier; - -/** - * Implementers can be written to a {@linkplain StreamOutput} and read from a {@linkplain StreamInput}. This allows them to be "thrown - * across the wire" using Elasticsearch's internal protocol. If the implementer also implements equals and hashCode then a copy made by - * serializing and deserializing must be equal and have the same hashCode. It isn't required that such a copy be entirely unchanged. - * - * Prefer implementing {@link Writeable} over implementing this interface where possible. Lots of code depends on this interface so this - * isn't always possible. - * - * Implementers of this interface almost always declare a no arg constructor that is exclusively used for creating "empty" objects on which - * you then call {@link #readFrom(StreamInput)}. Because {@linkplain #readFrom(StreamInput)} isn't part of the constructor the fields - * on implementers cannot be final. It is these reasons that this interface has fallen out of favor compared to {@linkplain Writeable}. - */ -public interface Streamable { - /** - * Set this object's fields from a {@linkplain StreamInput}. - */ - default void readFrom(StreamInput in) throws IOException { - throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); - } - - /** - * Write this object's fields to a {@linkplain StreamOutput}. - */ - void writeTo(StreamOutput out) throws IOException; - - static Writeable.Reader newWriteableReader(Supplier supplier) { - return (StreamInput in) -> { - T request = supplier.get(); - request.readFrom(in); - return request; - }; - } -} diff --git a/server/src/main/java/org/elasticsearch/common/io/stream/Writeable.java b/server/src/main/java/org/elasticsearch/common/io/stream/Writeable.java index 9d645038d65..82cc2323b1a 100644 --- a/server/src/main/java/org/elasticsearch/common/io/stream/Writeable.java +++ b/server/src/main/java/org/elasticsearch/common/io/stream/Writeable.java @@ -25,9 +25,6 @@ import java.io.IOException; * Implementers can be written to a {@linkplain StreamOutput} and read from a {@linkplain StreamInput}. This allows them to be "thrown * across the wire" using Elasticsearch's internal protocol. If the implementer also implements equals and hashCode then a copy made by * serializing and deserializing must be equal and have the same hashCode. It isn't required that such a copy be entirely unchanged. - *

- * Prefer implementing this interface over implementing {@link Streamable} where possible. Lots of code depends on {@linkplain Streamable} - * so this isn't always possible. */ public interface Writeable { diff --git a/server/src/main/java/org/elasticsearch/tasks/TaskInfo.java b/server/src/main/java/org/elasticsearch/tasks/TaskInfo.java index d01b8cfaa3c..bb9d7b7ef4b 100644 --- a/server/src/main/java/org/elasticsearch/tasks/TaskInfo.java +++ b/server/src/main/java/org/elasticsearch/tasks/TaskInfo.java @@ -48,7 +48,7 @@ import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optiona *

* Tasks are used for communication with transport actions. As a result, they can contain callback * references as well as mutable state. That makes it impractical to send tasks over transport channels - * and use in APIs. Instead, immutable and streamable TaskInfo objects are used to represent + * and use in APIs. Instead, immutable and writeable TaskInfo objects are used to represent * snapshot information about currently running tasks. */ public final class TaskInfo implements Writeable, ToXContentFragment { diff --git a/server/src/main/java/org/elasticsearch/transport/TransportMessage.java b/server/src/main/java/org/elasticsearch/transport/TransportMessage.java index f8e0f245416..43130874202 100644 --- a/server/src/main/java/org/elasticsearch/transport/TransportMessage.java +++ b/server/src/main/java/org/elasticsearch/transport/TransportMessage.java @@ -20,13 +20,10 @@ package org.elasticsearch.transport; import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.Streamable; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.transport.TransportAddress; -import java.io.IOException; - -public abstract class TransportMessage implements Streamable, Writeable { +public abstract class TransportMessage implements Writeable { private TransportAddress remoteAddress; @@ -41,18 +38,11 @@ public abstract class TransportMessage implements Streamable, Writeable { /** * Constructs a new empty transport message */ - public TransportMessage() { - } + public TransportMessage() {} /** * Constructs a new transport message with the data from the {@link StreamInput}. This is * currently a no-op */ - public TransportMessage(StreamInput in) throws IOException { - } - - @Override - public final void readFrom(StreamInput in) throws IOException { - throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); - } + public TransportMessage(StreamInput in) {} } diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/settings/put/UpdateSettingsRequestTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/settings/put/UpdateSettingsRequestTests.java index a0c82c094c3..ef2b13fc6d0 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/settings/put/UpdateSettingsRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/settings/put/UpdateSettingsRequestTests.java @@ -72,7 +72,7 @@ public class UpdateSettingsRequestTests extends AbstractXContentTestCase expected = new ArrayList<>(size);