Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ public static Metadata readFrom(StreamInput in) throws IOException {
for (int i = 0; i < size; i++) {
projectBuilder.put(IndexTemplateMetadata.readFrom(in));
}
readBwcCustoms(in, builder);
readBwcCustoms(in, builder, projectBuilder);

int reservedStateSize = in.readVInt();
for (int i = 0; i < reservedStateSize; i++) {
Expand All @@ -1229,7 +1229,7 @@ public static Metadata readFrom(StreamInput in) throws IOException {
return builder.build();
}

private static void readBwcCustoms(StreamInput in, Builder builder) throws IOException {
private static void readBwcCustoms(StreamInput in, Builder builder, ProjectMetadata.Builder projectBuilder) throws IOException {
final Set<String> clusterScopedNames = in.namedWriteableRegistry().getReaders(ClusterCustom.class).keySet();
final Set<String> projectScopedNames = in.namedWriteableRegistry().getReaders(ProjectCustom.class).keySet();
final int count = in.readVInt();
Expand All @@ -1245,9 +1245,9 @@ private static void readBwcCustoms(StreamInput in, Builder builder) throws IOExc
if (custom instanceof PersistentTasksCustomMetadata persistentTasksCustomMetadata) {
final var tuple = persistentTasksCustomMetadata.split();
builder.putCustom(tuple.v1().getWriteableName(), tuple.v1());
builder.putProjectCustom(tuple.v2().getWriteableName(), tuple.v2());
projectBuilder.putCustom(tuple.v2().getWriteableName(), tuple.v2());
} else {
builder.putProjectCustom(custom.getWriteableName(), custom);
projectBuilder.putCustom(custom.getWriteableName(), custom);
}
} else {
throw new IllegalArgumentException("Unknown custom name [" + name + "]");
Expand Down Expand Up @@ -1569,7 +1569,8 @@ public Builder putCustom(String type, ClusterCustom custom) {

@Deprecated(forRemoval = true)
public Builder putCustom(String type, ProjectCustom custom) {
return putProjectCustom(type, custom);
getSingleProject().putCustom(type, Objects.requireNonNull(custom, type));
return this;
}

public ClusterCustom getCustom(String type) {
Expand All @@ -1592,12 +1593,6 @@ public Builder customs(Map<String, ClusterCustom> clusterCustoms) {
return this;
}

@Deprecated(forRemoval = true)
public Builder putProjectCustom(String type, ProjectCustom custom) {
getSingleProject().putCustom(type, Objects.requireNonNull(custom, type));
return this;
}

@Deprecated(forRemoval = true)
public Builder projectCustoms(Map<String, ProjectCustom> projectCustoms) {
projectCustoms.forEach((key, value) -> Objects.requireNonNull(value, key));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,16 @@ private Tuple<Metadata, Metadata> randomMetadataAndUpdate() {
ClusterPersistentTasksCustomMetadata::new
)
)
.putProjectCustom(
PersistentTasksCustomMetadata.TYPE,
mutatePersistentTasks(
PersistentTasksCustomMetadata.get(before.getProject(Metadata.DEFAULT_PROJECT_ID)),
MetadataPersistentTasksTests::oneProjectPersistentTask,
PersistentTasksCustomMetadata::new
)
.put(
ProjectMetadata.builder(before.getProject(Metadata.DEFAULT_PROJECT_ID))
.putCustom(
PersistentTasksCustomMetadata.TYPE,
mutatePersistentTasks(
PersistentTasksCustomMetadata.get(before.getProject(Metadata.DEFAULT_PROJECT_ID)),
MetadataPersistentTasksTests::oneProjectPersistentTask,
PersistentTasksCustomMetadata::new
)
)
)
.build();
return new Tuple<>(before, after);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,6 @@ public void testBuilderRejectsNullCustom() {
expectThrows(NullPointerException.class, () -> builder.putCustom(key, (Metadata.ClusterCustom) null)).getMessage(),
containsString(key)
);
assertThat(expectThrows(NullPointerException.class, () -> builder.putProjectCustom(key, null)).getMessage(), containsString(key));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion is moved to ProjectMetadataTests in #130846, so I'm just removing it here as well to pass compilation.

}

public void testBuilderRejectsNullInCustoms() {
Expand Down