-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Fresa/dispose-network-client-as-client-is-…
…disposed Dispose network client as client is disposed
- Loading branch information
Showing
4 changed files
with
92 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Runtime.ExceptionServices; | ||
using System.Threading.Tasks; | ||
|
||
namespace Kafka.TestFramework | ||
{ | ||
internal static class TaskExtensions | ||
{ | ||
internal static async Task ThrowAllExceptions(this Task task) | ||
{ | ||
try | ||
{ | ||
await task.ConfigureAwait(false); | ||
} | ||
catch | ||
{ | ||
if (task.Exception?.InnerExceptions.Count > 1) | ||
{ | ||
ExceptionDispatchInfo.Capture(task.Exception).Throw(); | ||
} | ||
|
||
throw; | ||
} | ||
} | ||
|
||
internal static ValueTask AsValueTask(this Task task) => | ||
task.IsCompletedSuccessfully ? default : new ValueTask(task); | ||
} | ||
} |