Fix a rare GetAwaiter().GetResult() on a ValueTask in System.Net.Http (dotnet/corefx...
authorStephen Toub <stoub@microsoft.com>
Tue, 22 Oct 2019 14:23:15 +0000 (10:23 -0400)
committerGitHub <noreply@github.com>
Tue, 22 Oct 2019 14:23:15 +0000 (10:23 -0400)
commitd7a062e5cd297e255c80764017e09cc51196dfa6
treeff59e2f4681f0e2355766b18d699818e5a12f2e8
parent7aa2a0493e652de9440902ff8b8577b11a1013b0
Fix a rare GetAwaiter().GetResult() on a ValueTask in System.Net.Http (dotnet/corefx#41958)

* Fix a rare GetAwaiter().GetResult() on a ValueTask in System.Net.Http

If someone's custom HttpContent-derived type is implementing their async SerializeToStreamAsync with synchronous Write calls on the destination stream, and if that WriteAsync method returns an IValueTaskSource-based ValueTask that's not yet completed, this could throw an exception.   This is unlikely to actually negative impact anyone right now, but it's worth fixing.  This is one of the patterns an analyzer around ValueTasks will help find and fix.

* Update src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpBaseStream.cs

Commit migrated from https://github.com/dotnet/corefx/commit/f37f05d4a7d916f14980456e9ddb95d2708efa24
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpBaseStream.cs