Skip to content

Setting routing to null in some Builder methods can result in ?routing=null being part of the URL #1218

@Stexxen

Description

@Stexxen

Java API client version

9.3

Java version

25

Elasticsearch Version

9.3

Problem description

In 9.3 you changed the routing code to use a List<String> instead of String

Previously setting routing to null meant nothing as it was detected and not used. But in 9.3, setting routing to null creates a List of a single null element

public final Builder<TDocument> routing(String value, String... values) {
this.routing = _listAdd(this.routing, value, values);
return this;

Then on a build call this section is executed

if (ApiTypeHelper.isDefined(request.routing)) {
params.put("routing", request.routing.stream().map(v -> v).collect(Collectors.joining(",")));
}

which results in the following being appended to url

?routing=null

And elasticsearch then ends up looking for or adding the document in potential the wrong place (depending on how many shades are being used for that index).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions