Elastic Search RequestOptions race condition(Is this a bug)?

Notice the RequestOptions object has this line

public static final RequestOptions DEFAULT = new Builder(
        Collections.emptyList(), HeapBufferedResponseConsumerFactory.DEFAULT, null).build();

everything is private so I can't construct RequestOptions NOR can I construct the private Builder

if I create a two new Request(each on different threads) and both of them have...

private RequestOptions options = RequestOptions.DEFAULT;

and DEFAULT is static!!

If I call
requst.getOptions().getHeaders().add() //refers to the same DEFAULT object so that one is modified twice :(. instead of once in each thread.

then are modifying the same RequestOptions.DEFAULT object which is a race condition and a list ends up with 2 not 1 per request.

I can't figure out how to pass in my own RequestOptions to each Request object.

thanks,
Dean

Does the documentation helps? https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-low-usage-requests.html#java-rest-low-usage-request-options

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.