Skip to content

Commit 0df22af

Browse files
committed
Clean up unnessary rethrow
`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.
1 parent 331ea1e commit 0df22af

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

src/DotNetty.Handlers/Tls/TlsHandler.cs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -959,15 +959,7 @@ public override int EndRead(IAsyncResult asyncResult)
959959
Debug.Assert(this.readCompletionSource == null || this.readCompletionSource.Task == asyncResult);
960960
Contract.Assert(!((Task<int>)asyncResult).IsCanceled);
961961

962-
try
963-
{
964-
return ((Task<int>)asyncResult).Result;
965-
}
966-
catch (AggregateException ex)
967-
{
968-
ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
969-
throw; // unreachable
970-
}
962+
return ((Task<int>)asyncResult).GetAwaiter().GetResult();
971963
}
972964

973965
IAsyncResult PrepareSyncReadResult(int readBytes, object state)
@@ -1051,15 +1043,7 @@ public override void EndWrite(IAsyncResult asyncResult)
10511043
return;
10521044
}
10531045

1054-
try
1055-
{
1056-
((Task)asyncResult).Wait();
1057-
}
1058-
catch (AggregateException ex)
1059-
{
1060-
ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
1061-
throw;
1062-
}
1046+
((Task)asyncResult).GetAwaiter().GetResult();
10631047
}
10641048
#endif
10651049

0 commit comments

Comments
 (0)