Skip to content

Commit bf8c2a1

Browse files
committed
Merge pull request #1954 from elastic/fix/rethrow
fix #1947 favor throw; over e.RethrowKeepingStackTrace()
2 parents 6f07a55 + 54866f1 commit bf8c2a1

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

src/Elasticsearch.Net/Transport/Pipeline/RequestPipeline.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,7 @@ public ElasticsearchResponse<TReturn> CallElasticsearch<TReturn>(RequestData req
392392
(response as ElasticsearchResponse<Stream>)?.Body?.Dispose();
393393
audit.Event = AuditEvent.BadResponse;
394394
audit.Exception = e;
395-
e.RethrowKeepingStackTrace();
396-
return null; //dead code due to call to RethrowKeepingStackTrace()
395+
throw;
397396
}
398397
}
399398
}
@@ -419,8 +418,7 @@ public async Task<ElasticsearchResponse<TReturn>> CallElasticsearchAsync<TReturn
419418
(response as ElasticsearchResponse<Stream>)?.Body?.Dispose();
420419
audit.Event = AuditEvent.BadResponse;
421420
audit.Exception = e;
422-
e.RethrowKeepingStackTrace();
423-
return null; //dead code due to call to RethrowKeepingStackTrace()
421+
throw;
424422
}
425423
}
426424
}

src/Elasticsearch.Net/Transport/Transport.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@ public ElasticsearchResponse<TReturn> Request<TReturn>(HttpMethod method, string
8383
pipeline.MarkDead(node);
8484
seenExceptions.Add(pipelineException);
8585
}
86-
catch (ResolveException resolveException)
86+
catch (ResolveException)
8787
{
88-
resolveException.RethrowKeepingStackTrace();
89-
return null; //dead code due to call to RethrowKeepingStackTrace()
88+
throw;
9089
}
9190
catch (Exception killerException)
9291
{
@@ -148,10 +147,9 @@ public async Task<ElasticsearchResponse<TReturn>> RequestAsync<TReturn>(HttpMeth
148147
pipeline.MarkDead(node);
149148
seenExceptions.Add(pipelineException);
150149
}
151-
catch (ResolveException resolveException)
150+
catch (ResolveException)
152151
{
153-
resolveException.RethrowKeepingStackTrace();
154-
return null; //dead code due to call to RethrowKeepingStackTrace()
152+
throw;
155153
}
156154
catch (Exception killerException)
157155
{
@@ -186,7 +184,7 @@ private static void Ping(IRequestPipeline pipeline, Node node)
186184
catch (PipelineException e) when (e.Recoverable)
187185
{
188186
pipeline.SniffOnConnectionFailure();
189-
e.RethrowKeepingStackTrace();
187+
throw;
190188
}
191189
}
192190

@@ -199,7 +197,7 @@ private static async Task PingAsync(IRequestPipeline pipeline, Node node)
199197
catch (PipelineException e) when (e.Recoverable)
200198
{
201199
await pipeline.SniffOnConnectionFailureAsync().ConfigureAwait(false);
202-
e.RethrowKeepingStackTrace();
200+
throw;
203201
}
204202
}
205203

src/Tests/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# mode either u (unit test), i (integration test) or m (mixed mode)
2-
mode: m
2+
mode: u
33
# the elasticsearch version that should be started
44
elasticsearch_version: 2.2.0
55
# whether we want to forcefully reseed on the node, if you are starting the tests with a node already running

0 commit comments

Comments
 (0)