Skip to content

Commit

Permalink
Allow return null from ConnectionListener.AcceptAsync (#41453)
Browse files Browse the repository at this point in the history
Co-authored-by: Natalia Kondratyeva <[email protected]>

Backport of #41442 to release/5.0

As it was discussed in #41304, with current System.Net.Connections APIs, listeners need to throw from AcceptAsync when shutting down since AcceptAsync cannot return null. This PR allows AcceptAsync to return null, to avoid unnecessary first-chance exceptions when listeners are gracefully shutting down.
  • Loading branch information
github-actions[bot] authored Aug 28, 2020
1 parent cb2023c commit 1dfd943
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public abstract partial class ConnectionListener : System.IAsyncDisposable, Syst
protected ConnectionListener() { }
public abstract System.Net.Connections.IConnectionProperties ListenerProperties { get; }
public abstract System.Net.EndPoint? LocalEndPoint { get; }
public abstract System.Threading.Tasks.ValueTask<System.Net.Connections.Connection> AcceptAsync(System.Net.Connections.IConnectionProperties? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
public abstract System.Threading.Tasks.ValueTask<System.Net.Connections.Connection?> AcceptAsync(System.Net.Connections.IConnectionProperties? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
public void Dispose() { }
protected virtual void Dispose(bool disposing) { }
public System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public abstract class ConnectionListener : IAsyncDisposable, IDisposable
/// <param name="options">Options used to create the connection, if any.</param>
/// <param name="cancellationToken">A token used to cancel the asynchronous operation.</param>
/// <returns>A <see cref="ValueTask{TResult}"/> for the <see cref="Connection"/>.</returns>
public abstract ValueTask<Connection> AcceptAsync(IConnectionProperties? options = null, CancellationToken cancellationToken = default);
public abstract ValueTask<Connection?> AcceptAsync(IConnectionProperties? options = null, CancellationToken cancellationToken = default);

public void Dispose()
{
Expand Down

0 comments on commit 1dfd943

Please sign in to comment.