Skip to content

Commit

Permalink
Clean up unnessary rethrow
Browse files Browse the repository at this point in the history
`try{_=task.Result;}catch(AggregateException ex){ExceptionDispatchInfo.Capture(ex.InnerException).Throw();/*unreachable*/throw;}` => `task.GetAwaiter().GetResult()`, the latter one will not wrap Exception as AggregateException.
  • Loading branch information
yyjdelete committed May 24, 2020
1 parent 331ea1e commit 0df22af
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/DotNetty.Handlers/Tls/TlsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -959,15 +959,7 @@ public override int EndRead(IAsyncResult asyncResult)
Debug.Assert(this.readCompletionSource == null || this.readCompletionSource.Task == asyncResult);
Contract.Assert(!((Task<int>)asyncResult).IsCanceled);

try
{
return ((Task<int>)asyncResult).Result;
}
catch (AggregateException ex)
{
ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
throw; // unreachable
}
return ((Task<int>)asyncResult).GetAwaiter().GetResult();
}

IAsyncResult PrepareSyncReadResult(int readBytes, object state)
Expand Down Expand Up @@ -1051,15 +1043,7 @@ public override void EndWrite(IAsyncResult asyncResult)
return;
}

try
{
((Task)asyncResult).Wait();
}
catch (AggregateException ex)
{
ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
throw;
}
((Task)asyncResult).GetAwaiter().GetResult();
}
#endif

Expand Down

0 comments on commit 0df22af

Please sign in to comment.