-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Do not expand stacktraces when completion exception is rethrown multiple times #31375
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| using System.Runtime.CompilerServices; | ||
| using System.Runtime.InteropServices; | ||
| using System.Text; | ||
| using System.Text.RegularExpressions; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Xunit; | ||
|
|
@@ -238,6 +239,8 @@ void ThrowTestException() | |
| invalidOperationException = await Assert.ThrowsAsync<InvalidOperationException>(async () => await _pipe.Writer.FlushAsync()); | ||
| Assert.Equal("Reader exception", invalidOperationException.Message); | ||
| Assert.Contains("ThrowTestException", invalidOperationException.StackTrace); | ||
|
|
||
| Assert.Single(Regex.Matches(invalidOperationException.StackTrace, "Pipe.GetFlushResult")); | ||
| } | ||
|
|
||
| [Fact] | ||
|
|
@@ -304,6 +307,8 @@ void ThrowTestException() | |
| invalidOperationException = await Assert.ThrowsAsync<InvalidOperationException>(async () => await _pipe.Reader.ReadAsync()); | ||
| Assert.Equal("Writer exception", invalidOperationException.Message); | ||
| Assert.Contains("ThrowTestException", invalidOperationException.StackTrace); | ||
|
|
||
| Assert.Single(Regex.Matches(invalidOperationException.StackTrace, "Pipe.GetReadResult")); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you also want a test that if the same source exception is passed into multiple pipes it only returns a single entry? aspnet/KestrelHttpServer#2730 (comment)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But we can't guarantee that. Different instances of EDI would still mutate the same exception object.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. void Main()
{
Exception exception;
try
{
throw new Exception();
}
catch (Exception ex)
{
exception = ex;
}
var edi1 = ExceptionDispatchInfo.Capture(exception);
var edi2 = ExceptionDispatchInfo.Capture(exception);
try
{
edi1.Throw();
}
catch (Exception ex)
{
Console.WriteLine("***");
Console.WriteLine(ex.ToString());
}
try
{
edi1.Throw();
}
catch (Exception ex)
{
Console.WriteLine("***");
Console.WriteLine(ex.ToString());
}
try
{
edi2.Throw();
}
catch (Exception ex)
{
Console.WriteLine("***");
Console.WriteLine(ex.ToString());
}
try
{
edi2.Throw();
}
catch (Exception ex)
{
Console.WriteLine("***");
Console.WriteLine(ex.ToString());
}
}Doesn't seem to?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it does:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So Exception exception;
Exception exception1 = null;
Exception exception2 = null;
try
{
throw new Exception();
}
catch (Exception ex)
{
exception = ex;
}
var edi1 = ExceptionDispatchInfo.Capture(exception);
try
{
edi1.Throw();
}
catch (Exception ex)
{
Console.WriteLine("***");
exception1 = ex;
Console.WriteLine(ex.ToString());
}
var edi2 = ExceptionDispatchInfo.Capture(exception);
try
{
edi2.Throw();
}
catch (Exception ex)
{
Console.WriteLine("***");
exception2 = ex;
Console.WriteLine(ex.ToString());
}
Console.WriteLine("***");
Console.WriteLine(ReferenceEquals(exception, exception1));
Console.WriteLine(ReferenceEquals(exception, exception2));So it looks like its equivalent to |
||
| } | ||
|
|
||
| [Fact] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
s_completedNoExceptionnow that it is no longer used.https://github.com/dotnet/corefx/pull/31375/files#diff-ff9ac9c14f9484dcfcaa2332b6353541L16
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done