Skip to content

Fix code for adding an alias [DATAES-821] #1395

@spring-projects-issues

Description

@spring-projects-issues

sothawo opened DATAES-821 and commented

The code in addAlias is broken:

	public IndicesAliasesRequest.AliasActions aliasAction(AliasQuery query, IndexCoordinates index) {
		Assert.notNull(index, "No index defined for Alias");
		Assert.notNull(query.getAliasName(), "No alias defined");
		IndicesAliasesRequest.AliasActions aliasAction = IndicesAliasesRequest.AliasActions.add()
				.alias(query.getAliasName()).index(index.getIndexName());

		if (query.getFilterBuilder() != null) {
			aliasAction.filter(query.getFilterBuilder());
		} else if (query.getFilter() != null) {
			aliasAction.filter(query.getFilter());
		} else if (!StringUtils.isEmpty(query.getRouting())) {
			aliasAction.routing(query.getRouting());
		} else if (!StringUtils.isEmpty(query.getSearchRouting())) {
			aliasAction.searchRouting(query.getSearchRouting());
		} else if (!StringUtils.isEmpty(query.getIndexRouting())) {
			aliasAction.indexRouting(query.getIndexRouting());
		}
		return aliasAction;
	}

It makes no sense to have this if-else cascading. For the first two ones - filter - yes, but not for the rest


Affects: 3.2.7 (Moore SR7), 4.0 RC2 (Neumann)

Referenced from: pull request #451

Backported to: 3.2.8 (Moore SR8)

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core supporttype: bugA general bug

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions