Skip to content

Commit d212539

Browse files
committed
Fix stack overflow when accessing ApiCall and build on .net core
1 parent 96c803c commit d212539

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

src/Nest/CommonAbstractions/Response/ResponseBase.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,17 @@ public interface IResponse : IBodyWithApiCallDetails
2121
[JsonIgnore]
2222
bool IsValid { get; }
2323

24-
/// <summary>
25-
/// Returns the <see cref="IApiCallDetails"/> diagnostic information
26-
/// </summary>
27-
[JsonIgnore]
28-
new IApiCallDetails ApiCall { get; }
29-
3024
/// <summary>
3125
/// If the response results in an error on elasticsearch's side an <pre>error</pre> element will be returned, this is mapped to <see cref="ServerError"/> in NEST.
32-
/// <para>This property is a shortcut to <see cref="ApiCall"/>'s <see cref="IApiCallDetails.ServerError"/> and is possibly set when <see cref="IsValid"/> is false depending on the cause of the error</para>
26+
/// <para>This property is a shortcut to <see cref="IBodyWithApiCallDetails.ApiCall"/>'s <see cref="IApiCallDetails.ServerError"/> and is possibly set when <see cref="IsValid"/> is false depending on the cause of the error</para>
3327
/// <para>You can also configure the client to always throw an <see cref="ElasticsearchClientException"/> using <see cref="IConnectionConfigurationValues.ThrowExceptions"/> if the response is not valid</para>
3428
/// </summary>
3529
[JsonIgnore]
3630
ServerError ServerError { get; }
3731

3832
/// <summary>
3933
/// If the request resulted in an exception on the client side this will hold the exception that was thrown.
40-
/// <para>This property is a shortcut to <see cref="ApiCall"/>'s <see cref="IApiCallDetails.OriginalException"/> and is possibly set when <see cref="IsValid"/> is false depending on the cause of the error</para>
34+
/// <para>This property is a shortcut to <see cref="IBodyWithApiCallDetails.ApiCall"/>'s <see cref="IApiCallDetails.OriginalException"/> and is possibly set when <see cref="IsValid"/> is false depending on the cause of the error</para>
4135
/// <para>You can also configure the client to always throw an <see cref="ElasticsearchClientException"/> using <see cref="IConnectionConfigurationValues.ThrowExceptions"/> if the response is not valid</para>
4236
/// </summary>
4337
[JsonIgnore]
@@ -59,7 +53,7 @@ public abstract class ResponseBase : IResponse
5953
IApiCallDetails IBodyWithApiCallDetails.ApiCall { get; set; }
6054

6155
/// <inheritdoc/>
62-
public virtual IApiCallDetails ApiCall => ((IBodyWithApiCallDetails)this).ApiCall;
56+
protected virtual IApiCallDetails ApiCall => ((IBodyWithApiCallDetails)this).ApiCall;
6357

6458
/// <inheritdoc/>
6559
public virtual ServerError ServerError => this.ApiCall?.ServerError;

src/Nest/Search/Search/SearchResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public interface ISearchResponse<T> : IResponse where T : class
4242
public class SearchResponse<T> : ResponseBase, ISearchResponse<T> where T : class
4343
{
4444
internal ServerError MultiSearchError { get; set; }
45-
public override IApiCallDetails ApiCall => MultiSearchError != null ? new ApiCallDetailsOverride(base.ApiCall, MultiSearchError) : base.ApiCall;
45+
protected override IApiCallDetails ApiCall => MultiSearchError != null ? new ApiCallDetailsOverride(base.ApiCall, MultiSearchError) : base.ApiCall;
4646

4747
[JsonProperty(PropertyName = "_shards")]
4848
public ShardsMetaData Shards { get; internal set; }

src/Tests/ClientConcepts/Exceptions/ExceptionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void ServerTestWhenThrowExceptionsDisabled()
6060
var response = client.GetMapping<Project>(s => s.Index("doesntexist"));
6161
#if DOTNETCORE
6262
// HttpClient does not throw on "known error" status codes (i.e. 404) thus OriginalException should not be set
63-
response.CallDetails.OriginalException.Should().BeNull();
63+
response.ApiCall.OriginalException.Should().BeNull();
6464
#else
6565
response.ApiCall.OriginalException.Should().NotBeNull();
6666
#endif
@@ -76,7 +76,7 @@ public void ClientTestWhenThrowExceptionsDisabled()
7676
var response = client.RootNodeInfo();
7777
#if DOTNETCORE
7878
// HttpClient does not throw on "known error" status codes (i.e. 404) thus OriginalException should not be set
79-
response.CallDetails.OriginalException.Should().BeNull();
79+
response.ApiCall.OriginalException.Should().BeNull();
8080
#else
8181
response.ApiCall.OriginalException.Should().NotBeNull();
8282
#endif

0 commit comments

Comments
 (0)