Skip to content

Commit 8e91e6b

Browse files
ivan-samrusscam
authored andcommitted
Change RequestConfiguration.ThrowExceptions to bool? (#3231)
1 parent 2185270 commit 8e91e6b

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

src/Elasticsearch.Net/Configuration/RequestConfiguration.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public interface IRequestConfiguration
6969
/// <summary>
7070
/// Whether or not this request should be pipelined. http://en.wikipedia.org/wiki/HTTP_pipelining defaults to true
7171
/// </summary>
72-
bool EnableHttpPipelining { get; set; }
72+
bool? EnableHttpPipelining { get; set; }
7373

7474
/// <summary>
7575
/// Submit the request on behalf in the context of a different shield user
@@ -87,7 +87,7 @@ public interface IRequestConfiguration
8787
/// on the client when a call resulted in an exception on either the client or the Elasticsearch server.
8888
/// <para>Reasons for such exceptions could be search parser errors, index missing exceptions, etc...</para>
8989
/// </summary>
90-
bool ThrowExceptions { get; set; }
90+
bool? ThrowExceptions { get; set; }
9191
}
9292

9393
public class RequestConfiguration : IRequestConfiguration
@@ -103,7 +103,7 @@ public class RequestConfiguration : IRequestConfiguration
103103
public bool? DisableDirectStreaming { get; set; }
104104
public IEnumerable<int> AllowedStatusCodes { get; set; }
105105
public BasicAuthenticationCredentials BasicAuthenticationCredentials { get; set; }
106-
public bool EnableHttpPipelining { get; set; } = true;
106+
public bool? EnableHttpPipelining { get; set; } = true;
107107
public CancellationToken CancellationToken { get; set; }
108108
/// <summary>
109109
/// Submit the request on behalf in the context of a different user
@@ -112,7 +112,7 @@ public class RequestConfiguration : IRequestConfiguration
112112
public string RunAs { get; set; }
113113

114114
public X509CertificateCollection ClientCertificates { get; set; }
115-
public bool ThrowExceptions { get; set; }
115+
public bool? ThrowExceptions { get; set; }
116116
}
117117

118118
public class RequestConfigurationDescriptor : IRequestConfiguration
@@ -130,10 +130,10 @@ public class RequestConfigurationDescriptor : IRequestConfiguration
130130
bool? IRequestConfiguration.DisableDirectStreaming { get; set; }
131131
IEnumerable<int> IRequestConfiguration.AllowedStatusCodes { get; set; }
132132
BasicAuthenticationCredentials IRequestConfiguration.BasicAuthenticationCredentials { get; set; }
133-
bool IRequestConfiguration.EnableHttpPipelining { get; set; } = true;
133+
bool? IRequestConfiguration.EnableHttpPipelining { get; set; } = true;
134134
string IRequestConfiguration.RunAs { get; set; }
135135
X509CertificateCollection IRequestConfiguration.ClientCertificates { get; set; }
136-
bool IRequestConfiguration.ThrowExceptions { get; set; }
136+
bool? IRequestConfiguration.ThrowExceptions { get; set; }
137137

138138
public RequestConfigurationDescriptor(IRequestConfiguration config)
139139
{
@@ -151,6 +151,7 @@ public RequestConfigurationDescriptor(IRequestConfiguration config)
151151
Self.EnableHttpPipelining = config?.EnableHttpPipelining ?? true;
152152
Self.RunAs = config?.RunAs;
153153
Self.ClientCertificates = config?.ClientCertificates;
154+
Self.ThrowExceptions = config?.ThrowExceptions;
154155
}
155156

156157
/// <summary>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Elasticsearch.Net;
2+
using FluentAssertions;
3+
using System;
4+
using Tests.Framework;
5+
using Tests.Framework.ManagedElasticsearch.Clusters;
6+
using Xunit;
7+
8+
namespace Tests.Reproduce
9+
{
10+
public class GithubIssue3231 : IClusterFixture<ReadOnlyCluster>
11+
{
12+
private readonly ReadOnlyCluster _cluster;
13+
14+
public GithubIssue3231(ReadOnlyCluster cluster)
15+
{
16+
_cluster = cluster;
17+
}
18+
19+
[I]
20+
public void CatIndicesUsesThrowExceptionsFromConnectionSettingsWhenRequestSettingsAreNotSetTest()
21+
{
22+
var client = TestClient.GetClient(connectionSettings => connectionSettings.ThrowExceptions());
23+
Action catIndicesRequest = () => client.LowLevel.CatIndices<StringResponse>("non-existing-index");
24+
catIndicesRequest.ShouldThrow<ElasticsearchClientException>();
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)