Remove RepositoriesMetaData variadic constructor (#29569)
The variadic constructor was only used in a few places and the RepositoriesMetaData class is backed by a List anyway, so just using a List will make it simpler to instantiate it.
This commit is contained in:
parent
cdae8ff5a0
commit
62a9b8909e
|
@ -50,8 +50,8 @@ public class RepositoriesMetaData extends AbstractNamedDiffable<Custom> implemen
|
|||
*
|
||||
* @param repositories list of repositories
|
||||
*/
|
||||
public RepositoriesMetaData(RepositoryMetaData... repositories) {
|
||||
this.repositories = Arrays.asList(repositories);
|
||||
public RepositoriesMetaData(List<RepositoryMetaData> repositories) {
|
||||
this.repositories = repositories;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -164,7 +164,7 @@ public class RepositoriesMetaData extends AbstractNamedDiffable<Custom> implemen
|
|||
throw new ElasticsearchParseException("failed to parse repositories");
|
||||
}
|
||||
}
|
||||
return new RepositoriesMetaData(repository.toArray(new RepositoryMetaData[repository.size()]));
|
||||
return new RepositoriesMetaData(repository);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -114,7 +114,8 @@ public class RepositoriesService extends AbstractComponent implements ClusterSta
|
|||
RepositoriesMetaData repositories = metaData.custom(RepositoriesMetaData.TYPE);
|
||||
if (repositories == null) {
|
||||
logger.info("put repository [{}]", request.name);
|
||||
repositories = new RepositoriesMetaData(new RepositoryMetaData(request.name, request.type, request.settings));
|
||||
repositories = new RepositoriesMetaData(
|
||||
Collections.singletonList(new RepositoryMetaData(request.name, request.type, request.settings)));
|
||||
} else {
|
||||
boolean found = false;
|
||||
List<RepositoryMetaData> repositoriesMetaData = new ArrayList<>(repositories.repositories().size() + 1);
|
||||
|
@ -133,7 +134,7 @@ public class RepositoriesService extends AbstractComponent implements ClusterSta
|
|||
} else {
|
||||
logger.info("update repository [{}]", request.name);
|
||||
}
|
||||
repositories = new RepositoriesMetaData(repositoriesMetaData.toArray(new RepositoryMetaData[repositoriesMetaData.size()]));
|
||||
repositories = new RepositoriesMetaData(repositoriesMetaData);
|
||||
}
|
||||
mdBuilder.putCustom(RepositoriesMetaData.TYPE, repositories);
|
||||
return ClusterState.builder(currentState).metaData(mdBuilder).build();
|
||||
|
@ -185,7 +186,7 @@ public class RepositoriesService extends AbstractComponent implements ClusterSta
|
|||
}
|
||||
}
|
||||
if (changed) {
|
||||
repositories = new RepositoriesMetaData(repositoriesMetaData.toArray(new RepositoryMetaData[repositoriesMetaData.size()]));
|
||||
repositories = new RepositoriesMetaData(repositoriesMetaData);
|
||||
mdBuilder.putCustom(RepositoriesMetaData.TYPE, repositories);
|
||||
return ClusterState.builder(currentState).metaData(mdBuilder).build();
|
||||
}
|
||||
|
|
|
@ -640,7 +640,7 @@ public class ClusterStateDiffIT extends ESIntegTestCase {
|
|||
@Override
|
||||
public MetaData.Custom randomCreate(String name) {
|
||||
if (randomBoolean()) {
|
||||
return new RepositoriesMetaData();
|
||||
return new RepositoriesMetaData(Collections.emptyList());
|
||||
} else {
|
||||
return IndexGraveyardTests.createRandom();
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class RepositoriesMetaDataSerializationTests extends AbstractDiffableSeri
|
|||
entries.add(new RepositoryMetaData(randomAlphaOfLength(10), randomAlphaOfLength(10), randomSettings()));
|
||||
}
|
||||
entries.sort(Comparator.comparing(RepositoryMetaData::name));
|
||||
return new RepositoriesMetaData(entries.toArray(new RepositoryMetaData[entries.size()]));
|
||||
return new RepositoriesMetaData(entries);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,7 +62,7 @@ public class RepositoriesMetaDataSerializationTests extends AbstractDiffableSeri
|
|||
} else {
|
||||
entries.remove(randomIntBetween(0, entries.size() - 1));
|
||||
}
|
||||
return new RepositoriesMetaData(entries.toArray(new RepositoryMetaData[entries.size()]));
|
||||
return new RepositoriesMetaData(entries);
|
||||
}
|
||||
|
||||
public Settings randomSettings() {
|
||||
|
@ -94,7 +94,7 @@ public class RepositoriesMetaDataSerializationTests extends AbstractDiffableSeri
|
|||
repos.add(new RepositoryMetaData(randomAlphaOfLength(10), randomAlphaOfLength(10), randomSettings()));
|
||||
}
|
||||
}
|
||||
return new RepositoriesMetaData(repos.toArray(new RepositoryMetaData[repos.size()]));
|
||||
return new RepositoriesMetaData(repos);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -114,7 +114,7 @@ public class RepositoriesMetaDataSerializationTests extends AbstractDiffableSeri
|
|||
assertEquals(XContentParser.Token.END_OBJECT, parser.currentToken());
|
||||
List<RepositoryMetaData> repos = repositoriesMetaData.repositories();
|
||||
repos.sort(Comparator.comparing(RepositoryMetaData::name));
|
||||
return new RepositoriesMetaData(repos.toArray(new RepositoryMetaData[repos.size()]));
|
||||
return new RepositoriesMetaData(repos);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class LicensesMetaDataSerializationTests extends ESTestCase {
|
|||
License license = TestUtils.generateSignedLicense(TimeValue.timeValueHours(2));
|
||||
LicensesMetaData licensesMetaData = new LicensesMetaData(license, Version.CURRENT);
|
||||
RepositoryMetaData repositoryMetaData = new RepositoryMetaData("repo", "fs", Settings.EMPTY);
|
||||
RepositoriesMetaData repositoriesMetaData = new RepositoriesMetaData(repositoryMetaData);
|
||||
RepositoriesMetaData repositoriesMetaData = new RepositoriesMetaData(Collections.singletonList(repositoryMetaData));
|
||||
final MetaData.Builder metaDataBuilder = MetaData.builder();
|
||||
if (randomBoolean()) { // random order of insertion
|
||||
metaDataBuilder.putCustom(licensesMetaData.getWriteableName(), licensesMetaData);
|
||||
|
|
|
@ -47,7 +47,7 @@ public class WatcherMetaDataSerializationTests extends ESTestCase {
|
|||
boolean manuallyStopped = randomBoolean();
|
||||
WatcherMetaData watcherMetaData = new WatcherMetaData(manuallyStopped);
|
||||
RepositoryMetaData repositoryMetaData = new RepositoryMetaData("repo", "fs", Settings.EMPTY);
|
||||
RepositoriesMetaData repositoriesMetaData = new RepositoriesMetaData(repositoryMetaData);
|
||||
RepositoriesMetaData repositoriesMetaData = new RepositoriesMetaData(Collections.singletonList(repositoryMetaData));
|
||||
final MetaData.Builder metaDataBuilder = MetaData.builder();
|
||||
if (randomBoolean()) { // random order of insertion
|
||||
metaDataBuilder.putCustom(watcherMetaData.getWriteableName(), watcherMetaData);
|
||||
|
|
Loading…
Reference in New Issue