Skip to content

Commit

Permalink
adding null check on provider registration
Browse files Browse the repository at this point in the history
  • Loading branch information
ovebastiansen committed Dec 12, 2020
1 parent 51333a0 commit 29a9add
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
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

0 comments on commit 29a9add

Please sign in to comment.