Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding null check on provider registration #46002

Merged
merged 1 commit into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ public void AddProvider(ILoggerProvider provider)
throw new ObjectDisposedException(nameof(LoggerFactory));
}

if (provider == null)
{
throw new ArgumentNullException(nameof(provider));
}

lock (_sync)
{
AddProviderRegistration(provider, dispose: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ public void AddProvider_ThrowsAfterDisposed()
Assert.Throws<ObjectDisposedException>(() => ((ILoggerFactory) factory).AddProvider(CreateProvider()));
}

[Fact]
public void AddProvider_ThrowsIfProviderIsNull()
{
var factory = new LoggerFactory();

Assert.Throws<ArgumentNullException>(() => ((ILoggerFactory)factory).AddProvider(null));
}

[Fact]
public void CreateLogger_ThrowsAfterDisposed()
{
Expand Down