From 7b247fe41e06b330b675e27365279015231a0092 Mon Sep 17 00:00:00 2001 From: Colin Goodheart-Smithe Date: Thu, 12 Apr 2018 12:15:36 +0100 Subject: [PATCH] Fixes compile errors from TimeValue serialisation --- .../xpack/core/indexlifecycle/Phase.java | 4 ++-- .../xpack/core/indexlifecycle/RolloverAction.java | 12 ++---------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/Phase.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/Phase.java index a4da8252211..e8f9b90f3c3 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/Phase.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/Phase.java @@ -82,7 +82,7 @@ public class Phase implements ToXContentObject, Writeable { */ public Phase(StreamInput in) throws IOException { this.name = in.readString(); - this.after = new TimeValue(in); + this.after = in.readTimeValue(); int size = in.readVInt(); TreeMap actions = new TreeMap<>(); for (int i = 0; i < size; i++) { @@ -94,7 +94,7 @@ public class Phase implements ToXContentObject, Writeable { @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(name); - after.writeTo(out); + out.writeTimeValue(after); out.writeVInt(actions.size()); for (Map.Entry entry : actions.entrySet()) { out.writeString(entry.getKey()); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/RolloverAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/RolloverAction.java index ecce11fcbb2..707f86ae6e5 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/RolloverAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/RolloverAction.java @@ -73,11 +73,7 @@ public class RolloverAction implements LifecycleAction { } else { maxSize = null; } - if (in.readBoolean()) { - maxAge = new TimeValue(in); - } else { - maxAge = null; - } + maxAge = in.readOptionalTimeValue(); if (in.readBoolean()) { maxDocs = in.readVLong(); } else { @@ -93,11 +89,7 @@ public class RolloverAction implements LifecycleAction { if (hasMaxSize) { maxSize.writeTo(out); } - boolean hasMaxAge = maxAge != null; - out.writeBoolean(hasMaxAge); - if (hasMaxAge) { - maxAge.writeTo(out); - } + out.writeOptionalTimeValue(maxAge); boolean hasMaxDocs = maxDocs != null; out.writeBoolean(hasMaxDocs); if (hasMaxDocs) {