Skip to content

ElasticLowLevelClient returns the same VoidResponse instance from subsequent requests #3585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
t3j3x6 opened this issue Mar 4, 2019 · 1 comment

Comments

@t3j3x6
Copy link

t3j3x6 commented Mar 4, 2019

Elasticsearch.Net: 6.0.0 through 6.5.0. Does not reproduce on 5.6.5.
Elasticsearch version: 6.6.0

When using the VoidResponse response type, each request returns the same VoidResponse instance, modifying its ApiCall property. For StringResponse, BytesResponse and DynamicResponse a new instance is returned. Using a different ElasticLowLevelClient instance does not change this behavior. Here's a small demonstration:

var connectionConfiguration = new ConnectionConfiguration(
	new SingleNodeConnectionPool(new Uri("http://127.0.0.1:9200")),
	new HttpConnection());
var client = new ElasticLowLevelClient(connectionConfiguration);

var voidResponse1 = await client.IndicesCreateAsync<VoidResponse>("foo", null);
var originalApiCall = voidResponse1.ApiCall;
Console.WriteLine($"{voidResponse1.HttpMethod}"); // PUT

var voidResponse2 = await client.IndicesDeleteAsync<VoidResponse>("foo");
var modifiedApiCall = voidResponse1.ApiCall;
Console.WriteLine($"{voidResponse1.HttpMethod}"); // DELETE

Console.WriteLine($"{ReferenceEquals(voidResponse1, voidResponse2)}"); // true
Console.WriteLine($"{ReferenceEquals(originalApiCall, modifiedApiCall)}"); // false

var stringResponse1 = await client.IndicesCreateAsync<StringResponse>("foo", null);
var stringResponse2 = await client.IndicesDeleteAsync<StringResponse>("foo");
Console.WriteLine($"{ReferenceEquals(stringResponse1, stringResponse2)}"); // false

var byteResponse1 = await client.IndicesCreateAsync<BytesResponse>("foo", null);
var byteResponse2 = await client.IndicesDeleteAsync<BytesResponse>("foo");
Console.WriteLine($"{ReferenceEquals(byteResponse1, byteResponse2)}"); // false

var dynamicResponse1 = await client.IndicesCreateAsync<DynamicResponse>("foo", null);
var dynamicResponse2 = await client.IndicesDeleteAsync<DynamicResponse>("foo");
Console.WriteLine($"{ReferenceEquals(dynamicResponse1, dynamicResponse2)}"); // false
@Mpdreamz
Copy link
Member

Mpdreamz commented Mar 4, 2019

Thank you for reporting this @t3j3x6 opened #3588 to address this.

@russcam russcam closed this as completed in 2c698bc Mar 6, 2019
SukharevAndrey pushed a commit to SukharevAndrey/elasticsearch-net that referenced this issue Mar 13, 2019
russcam pushed a commit that referenced this issue Apr 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants