From 82014ebec331a058e545ddfc99f8ffb5287d1664 Mon Sep 17 00:00:00 2001 From: javanna Date: Thu, 24 Mar 2016 15:22:31 +0100 Subject: [PATCH] use read/writeOptionalWriteable --- .../cluster/node/liveness/LivenessResponse.java | 13 ++----------- .../transport/ConnectTransportException.java | 13 ++----------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/liveness/LivenessResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/liveness/LivenessResponse.java index 169261ac6f2..f7ecfbaed4b 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/liveness/LivenessResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/liveness/LivenessResponse.java @@ -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() { diff --git a/core/src/main/java/org/elasticsearch/transport/ConnectTransportException.java b/core/src/main/java/org/elasticsearch/transport/ConnectTransportException.java index 515cdcc941f..cd3bf87a169 100644 --- a/core/src/main/java/org/elasticsearch/transport/ConnectTransportException.java +++ b/core/src/main/java/org/elasticsearch/transport/ConnectTransportException.java @@ -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() {