From 62763b177dd771c3a18d4581412555685a661f4e Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Sun, 5 Jul 2020 22:05:38 -0400 Subject: [PATCH] Implement toString for BulkByScrollTask (#59042) We should implement "toString" of BulkByScrollTask.StatusOrException to have a meaningful log message when a reindex task completes. --- .../elasticsearch/index/reindex/BulkByScrollTask.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollTask.java b/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollTask.java index f60b6fc85e1..9dff6fe9cb1 100644 --- a/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollTask.java +++ b/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollTask.java @@ -22,6 +22,7 @@ package org.elasticsearch.index.reindex; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseField; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -985,6 +986,15 @@ public class BulkByScrollTask extends CancellableTask { } } + @Override + public String toString() { + if (exception != null) { + return "BulkByScrollTask{error=" + Strings.toString(this) + "}"; + } else { + return "BulkByScrollTask{status=" + Strings.toString(this) + "}"; + } + } + @Override public boolean equals(Object obj) { if (obj == null) {