From 6fbc3b88321cae3e5b96c790c3cdbc388ccf54b1 Mon Sep 17 00:00:00 2001 From: Kristian Hellang Date: Tue, 8 Dec 2015 10:58:42 +0100 Subject: [PATCH] Added null check in KestrelServerInformation --- .../KestrelServerInformation.cs | 5 +++++ .../KestrelServerInformationTests.cs | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/Microsoft.AspNet.Server.Kestrel/KestrelServerInformation.cs b/src/Microsoft.AspNet.Server.Kestrel/KestrelServerInformation.cs index 3808b6144b..f9f4ae8c8e 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/KestrelServerInformation.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/KestrelServerInformation.cs @@ -14,6 +14,11 @@ namespace Microsoft.AspNet.Server.Kestrel { public KestrelServerInformation(IConfiguration configuration) { + if (configuration == null) + { + throw new ArgumentNullException(nameof(configuration)); + } + Addresses = GetAddresses(configuration); ThreadCount = GetThreadCount(configuration); NoDelay = GetNoDelay(configuration); diff --git a/test/Microsoft.AspNet.Server.KestrelTests/KestrelServerInformationTests.cs b/test/Microsoft.AspNet.Server.KestrelTests/KestrelServerInformationTests.cs index 1c56258554..2513d93e84 100644 --- a/test/Microsoft.AspNet.Server.KestrelTests/KestrelServerInformationTests.cs +++ b/test/Microsoft.AspNet.Server.KestrelTests/KestrelServerInformationTests.cs @@ -11,6 +11,12 @@ namespace Microsoft.AspNet.Server.KestrelTests { public class KestrelServerInformationTests { + [Fact] + public void NullConfigurationThrows() + { + Assert.Throws(() => new KestrelServerInformation(null)); + } + [Fact] public void SetThreadCountUsingConfiguration() {