|
1 | 1 | using System; |
2 | 2 | using System.CodeDom; |
3 | 3 | using System.Collections.Generic; |
| 4 | +using System.ComponentModel; |
4 | 5 | using System.Configuration; |
5 | 6 | using System.Globalization; |
6 | 7 | using System.Linq; |
|
12 | 13 | using System.Threading.Tasks; |
13 | 14 | using Elasticsearch.Net; |
14 | 15 | using Elasticsearch.Net.Connection; |
| 16 | +using Elasticsearch.Net.ConnectionPool; |
15 | 17 | using Elasticsearch.Net.Exceptions; |
16 | 18 | using Elasticsearch.Net.Serialization; |
17 | 19 |
|
@@ -125,8 +127,12 @@ public bool SuccessOrKnownError |
125 | 127 | { |
126 | 128 | get |
127 | 129 | { |
| 130 | + var pool = this.Settings.ConnectionPool; |
| 131 | + var usingPool = pool != null && pool.GetType() != typeof(SingleNodeConnectionPool); |
| 132 | + |
128 | 133 | return this.Success || |
129 | | - (this.HttpStatusCode.HasValue |
| 134 | + (!usingPool && this.HttpStatusCode.GetValueOrDefault(1) < 0) |
| 135 | + || (this.HttpStatusCode.HasValue |
130 | 136 | && this.HttpStatusCode.Value != 503 //service unavailable needs to be retried |
131 | 137 | && this.HttpStatusCode.Value != 502 //bad gateway needs to be retried |
132 | 138 | && ((this.HttpStatusCode.Value >= 400 && this.HttpStatusCode.Value < 599))); |
@@ -162,22 +168,26 @@ public static ElasticsearchResponse<T> CreateError(IConnectionConfigurationValue |
162 | 168 | return cs; |
163 | 169 | } |
164 | 170 |
|
165 | | - public static ElasticsearchResponse<T> Create(IConnectionConfigurationValues settings, int statusCode, string method, string path, byte[] request) |
| 171 | + public static ElasticsearchResponse<T> Create( |
| 172 | + IConnectionConfigurationValues settings, int statusCode, string method, string path, byte[] request, Exception innerException = null) |
166 | 173 | { |
167 | 174 | var cs = new ElasticsearchResponse<T>(settings, statusCode); |
168 | 175 | cs.Request = request; |
169 | 176 | cs.RequestUrl = path; |
170 | 177 | cs.RequestMethod = method; |
| 178 | + cs.OriginalException = innerException; |
171 | 179 | return cs; |
172 | 180 | } |
173 | 181 |
|
174 | | - public static ElasticsearchResponse<T> Create(IConnectionConfigurationValues settings, int statusCode, string method, string path, byte[] request, T response) |
| 182 | + public static ElasticsearchResponse<T> Create( |
| 183 | + IConnectionConfigurationValues settings, int statusCode, string method, string path, byte[] request, T response, Exception innerException = null) |
175 | 184 | { |
176 | 185 | var cs = new ElasticsearchResponse<T>(settings, statusCode); |
177 | 186 | cs.Request = request; |
178 | 187 | cs.RequestUrl = path; |
179 | 188 | cs.RequestMethod = method; |
180 | 189 | cs.Response = response; |
| 190 | + cs.OriginalException = innerException; |
181 | 191 | return cs; |
182 | 192 | } |
183 | 193 |
|
|
0 commit comments