Skip to content

Commit

Permalink
Fix Empty Step Info not Comparing Correctly
Browse files Browse the repository at this point in the history
Follow up to elastic#78390. The `EmptyInfo` would not compare
correctly because it doesn't implement equals or hashcode,
breaking deduplication for `SetStepInfoUpdateTask`.

=> just making it a singleton to fix this and have a fast comp via
instance equality.
  • Loading branch information
original-brownbear committed Sep 29, 2021
1 parent 2fdb5a8 commit c26a33b
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void evaluateCondition(Metadata metadata, Index index, Listener listener,
logger.warn("index [{}] is not the write index for data stream [{}]. skipping rollover for policy [{}]",
index.getName(), dataStream.getName(),
LifecycleSettings.LIFECYCLE_NAME_SETTING.get(metadata.index(index).getSettings()));
listener.onResponse(true, new WaitForRolloverReadyStep.EmptyInfo());
listener.onResponse(true, EmptyInfo.INSTANCE);
return;
}
rolloverTarget = dataStream.getName();
Expand All @@ -83,7 +83,7 @@ public void evaluateCondition(Metadata metadata, Index index, Listener listener,
if (indexMetadata.getRolloverInfos().get(rolloverAlias) != null) {
logger.info("index [{}] was already rolled over for alias [{}], not attempting to roll over again",
index.getName(), rolloverAlias);
listener.onResponse(true, new WaitForRolloverReadyStep.EmptyInfo());
listener.onResponse(true, EmptyInfo.INSTANCE);
return;
}

Expand Down Expand Up @@ -117,7 +117,7 @@ public void evaluateCondition(Metadata metadata, Index index, Listener listener,
return;
}

listener.onResponse(true, new WaitForRolloverReadyStep.EmptyInfo());
listener.onResponse(true, EmptyInfo.INSTANCE);
return;
}

Expand Down Expand Up @@ -155,7 +155,7 @@ public void evaluateCondition(Metadata metadata, Index index, Listener listener,
}
getClient().admin().indices().rolloverIndex(rolloverRequest,
ActionListener.wrap(response -> listener.onResponse(response.getConditionStatus().values().stream().anyMatch(i -> i),
new WaitForRolloverReadyStep.EmptyInfo()), listener::onFailure));
EmptyInfo.INSTANCE), listener::onFailure));
}

ByteSizeValue getMaxSize() {
Expand Down Expand Up @@ -196,7 +196,10 @@ public boolean equals(Object obj) {
}

// We currently have no information to provide for this AsyncWaitStep, so this is an empty object
private class EmptyInfo implements ToXContentObject {
private static final class EmptyInfo implements ToXContentObject {

static final EmptyInfo INSTANCE = new EmptyInfo();

private EmptyInfo() {
}

Expand Down

0 comments on commit c26a33b

Please sign in to comment.