Don't swallow OCE unconditionally (dotnet/corefx#38473)
authorDavid Fowler <davidfowl@gmail.com>
Wed, 12 Jun 2019 16:09:54 +0000 (09:09 -0700)
committerGitHub <noreply@github.com>
Wed, 12 Jun 2019 16:09:54 +0000 (09:09 -0700)
commitc1a10c7c475cd2b8db53b9593aab3d136a4011f1
tree476acbf893b60a423fdb5bded18a53732cc3c2ed
parentf61d6e51eaacf36a0f54b322e33764188a764162
Don't swallow OCE unconditionally (dotnet/corefx#38473)

- Today we swallow OperationCanceledExceptions to avoid throwing if CancelPendingRead/CancelPendingFlush, this unintentionally swallows all exceptions that derive from OperationCancelled that were triggered by the ReadAsync call itself. This change rethrows the error unless we're in that specific case of having called one of those Cancel* methods.
- Added tests and did some other small test cleanup.

Commit migrated from https://github.com/dotnet/corefx/commit/b3d3267abca4ae5bd8d4542a02c08a3173ae1ab9
src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/StreamPipeReader.cs
src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/StreamPipeWriter.cs
src/libraries/System.IO.Pipelines/tests/StreamPipeReaderTests.cs
src/libraries/System.IO.Pipelines/tests/StreamPipeWriterTests.cs