From 54866f12b7469eb96c41c1fd7b591d991e4186e3 Mon Sep 17 00:00:00 2001 From: Mpdreamz Date: Wed, 23 Mar 2016 14:30:00 +0100 Subject: [PATCH] fix #1947 favor throw; over e.RethrowKeepingStackTrace() The latter is only good for rethrowing inner exceptions, which no longer serves a purpose in the refactored 2.x world` ty for raising this @TioLuiso --- .../Transport/Pipeline/RequestPipeline.cs | 6 ++---- src/Elasticsearch.Net/Transport/Transport.cs | 14 ++++++-------- src/Tests/tests.yaml | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/Elasticsearch.Net/Transport/Pipeline/RequestPipeline.cs b/src/Elasticsearch.Net/Transport/Pipeline/RequestPipeline.cs index 5087d506dde..8f712ead897 100644 --- a/src/Elasticsearch.Net/Transport/Pipeline/RequestPipeline.cs +++ b/src/Elasticsearch.Net/Transport/Pipeline/RequestPipeline.cs @@ -392,8 +392,7 @@ public ElasticsearchResponse CallElasticsearch(RequestData req (response as ElasticsearchResponse)?.Body?.Dispose(); audit.Event = AuditEvent.BadResponse; audit.Exception = e; - e.RethrowKeepingStackTrace(); - return null; //dead code due to call to RethrowKeepingStackTrace() + throw; } } } @@ -419,8 +418,7 @@ public async Task> CallElasticsearchAsync)?.Body?.Dispose(); audit.Event = AuditEvent.BadResponse; audit.Exception = e; - e.RethrowKeepingStackTrace(); - return null; //dead code due to call to RethrowKeepingStackTrace() + throw; } } } diff --git a/src/Elasticsearch.Net/Transport/Transport.cs b/src/Elasticsearch.Net/Transport/Transport.cs index 8eb429b7be6..32708036e06 100644 --- a/src/Elasticsearch.Net/Transport/Transport.cs +++ b/src/Elasticsearch.Net/Transport/Transport.cs @@ -83,10 +83,9 @@ public ElasticsearchResponse Request(HttpMethod method, string pipeline.MarkDead(node); seenExceptions.Add(pipelineException); } - catch (ResolveException resolveException) + catch (ResolveException) { - resolveException.RethrowKeepingStackTrace(); - return null; //dead code due to call to RethrowKeepingStackTrace() + throw; } catch (Exception killerException) { @@ -148,10 +147,9 @@ public async Task> RequestAsync(HttpMeth pipeline.MarkDead(node); seenExceptions.Add(pipelineException); } - catch (ResolveException resolveException) + catch (ResolveException) { - resolveException.RethrowKeepingStackTrace(); - return null; //dead code due to call to RethrowKeepingStackTrace() + throw; } catch (Exception killerException) { @@ -186,7 +184,7 @@ private static void Ping(IRequestPipeline pipeline, Node node) catch (PipelineException e) when (e.Recoverable) { pipeline.SniffOnConnectionFailure(); - e.RethrowKeepingStackTrace(); + throw; } } @@ -199,7 +197,7 @@ private static async Task PingAsync(IRequestPipeline pipeline, Node node) catch (PipelineException e) when (e.Recoverable) { await pipeline.SniffOnConnectionFailureAsync().ConfigureAwait(false); - e.RethrowKeepingStackTrace(); + throw; } } diff --git a/src/Tests/tests.yaml b/src/Tests/tests.yaml index 74cf2393ae3..0ea63a0af78 100644 --- a/src/Tests/tests.yaml +++ b/src/Tests/tests.yaml @@ -1,5 +1,5 @@ # mode either u (unit test), i (integration test) or m (mixed mode) -mode: m +mode: u # the elasticsearch version that should be started elasticsearch_version: 2.2.0 # whether we want to forcefully reseed on the node, if you are starting the tests with a node already running