use read/writeOptionalWriteable

This commit is contained in:
javanna 2016-03-24 15:22:31 +01:00 committed by Luca Cavanna
parent 06fd61fb00
commit 82014ebec3
2 changed files with 4 additions and 22 deletions

View File

@ -48,23 +48,14 @@ public final class LivenessResponse extends ActionResponse {
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
clusterName = ClusterName.readClusterName(in);
if (in.readBoolean()) {
node = DiscoveryNode.readNode(in);
} else {
node = null;
}
in.readOptionalWritable(DiscoveryNode::new);
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
clusterName.writeTo(out);
if (node == null) {
out.writeBoolean(false);
} else {
out.writeBoolean(true);
node.writeTo(out);
}
out.writeOptionalWriteable(node);
}
public ClusterName getClusterName() {

View File

@ -51,22 +51,13 @@ public class ConnectTransportException extends ActionTransportException {
public ConnectTransportException(StreamInput in) throws IOException {
super(in);
if (in.readBoolean()) {
node = new DiscoveryNode(in);
} else {
node = null;
}
node = in.readOptionalWritable(DiscoveryNode::new);
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
if (node == null) {
out.writeBoolean(false);
} else {
out.writeBoolean(true);
node.writeTo(out);
}
out.writeOptionalWriteable(node);
}
public DiscoveryNode node() {