Skip to content

Commit 5c7cf55

Browse files
asce0705joegallo
authored andcommitted
Fix incorrect generic type in PolicyStepsRegistry (#78628)
1 parent b3a4218 commit 5c7cf55

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/PolicyStepsRegistry.java

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.elasticsearch.ElasticsearchException;
1212
import org.elasticsearch.client.Client;
1313
import org.elasticsearch.cluster.ClusterState;
14-
import org.elasticsearch.cluster.Diff;
1514
import org.elasticsearch.cluster.DiffableUtils;
1615
import org.elasticsearch.cluster.metadata.IndexMetadata;
1716
import org.elasticsearch.cluster.metadata.Metadata;
@@ -92,32 +91,29 @@ Map<String, Map<Step.StepKey, Step>> getStepMap() {
9291
return stepMap;
9392
}
9493

95-
@SuppressWarnings({ "unchecked", "rawtypes" })
9694
public void update(ClusterState clusterState) {
9795
final IndexLifecycleMetadata meta = clusterState.metadata().custom(IndexLifecycleMetadata.TYPE);
98-
9996
assert meta != null : "IndexLifecycleMetadata cannot be null when updating the policy steps registry";
10097

101-
Diff<Map<String, LifecyclePolicyMetadata>> diff = DiffableUtils.diff(lifecyclePolicyMap, meta.getPolicyMetadatas(),
102-
DiffableUtils.getStringKeySerializer(),
103-
// Use a non-diffable value serializer. Otherwise actions in the same
104-
// action and phase that are changed show up as diffs instead of upserts.
105-
// We want to treat any change in the policy as an upsert so the map is
106-
// correctly rebuilt
107-
new DiffableUtils.NonDiffableValueSerializer<String, LifecyclePolicyMetadata>() {
108-
@Override
109-
public void write(LifecyclePolicyMetadata value, StreamOutput out) {
110-
// This is never called
111-
throw new UnsupportedOperationException("should never be called");
112-
}
98+
DiffableUtils.MapDiff<String, LifecyclePolicyMetadata, Map<String, LifecyclePolicyMetadata>> mapDiff =
99+
DiffableUtils.diff(lifecyclePolicyMap, meta.getPolicyMetadatas(), DiffableUtils.getStringKeySerializer(),
100+
// Use a non-diffable value serializer. Otherwise actions in the same
101+
// action and phase that are changed show up as diffs instead of upserts.
102+
// We want to treat any change in the policy as an upsert so the map is
103+
// correctly rebuilt
104+
new DiffableUtils.NonDiffableValueSerializer<String, LifecyclePolicyMetadata>() {
105+
@Override
106+
public void write(LifecyclePolicyMetadata value, StreamOutput out) {
107+
// This is never called
108+
throw new UnsupportedOperationException("should never be called");
109+
}
113110

114-
@Override
115-
public LifecyclePolicyMetadata read(StreamInput in, String key) {
116-
// This is never called
117-
throw new UnsupportedOperationException("should never be called");
118-
}
119-
});
120-
DiffableUtils.MapDiff<String, LifecyclePolicyMetadata, DiffableUtils.KeySerializer<String>> mapDiff = (DiffableUtils.MapDiff) diff;
111+
@Override
112+
public LifecyclePolicyMetadata read(StreamInput in, String key) {
113+
// This is never called
114+
throw new UnsupportedOperationException("should never be called");
115+
}
116+
});
121117

122118
for (String deletedPolicyName : mapDiff.getDeletes()) {
123119
lifecyclePolicyMap.remove(deletedPolicyName);
@@ -128,7 +124,7 @@ public LifecyclePolicyMetadata read(StreamInput in, String key) {
128124
if (mapDiff.getUpserts().isEmpty() == false) {
129125
for (LifecyclePolicyMetadata policyMetadata : mapDiff.getUpserts().values()) {
130126
LifecyclePolicySecurityClient policyClient = new LifecyclePolicySecurityClient(client, ClientHelper.INDEX_LIFECYCLE_ORIGIN,
131-
policyMetadata.getHeaders());
127+
policyMetadata.getHeaders());
132128
lifecyclePolicyMap.put(policyMetadata.getName(), policyMetadata);
133129
List<Step> policyAsSteps = policyMetadata.getPolicy().toSteps(policyClient, licenseState);
134130
if (policyAsSteps.isEmpty() == false) {

0 commit comments

Comments
 (0)