Bug 20818

Summary: System.Net.Http.DelegatingHandler.Dispose() throws NullReferenceException if InnerHandler not assigned
Product: [Mono] Class Libraries Reporter: Paul Turner <programming.hero>
Component: GeneralAssignee: Marek Safar <masafa>
Severity: normal CC: masafa, mono-bugs+mono
Priority: ---    
Version: 3.4.0   
Target Milestone: Untriaged   
Hardware: PC   
OS: Windows   
Tags: Is this bug a regression?: ---
Last known good build:

Description Paul Turner 2014-06-23 11:42:42 UTC
When disposed, the System.Net.Http.DelegatingHandler does not check whether the InnerHandler is set before calling Dispose, which raises NullReferenceException.

The following illustrates the issue:

	class TestHandler : System.Net.Http.DelegatingHandler

	class Program
		static void Main(string[] args)
			var handler = new TestHandler();

This behaviour deviates from the Microsoft implementation which throws no exception.

A simple fix would be to check whether the property is null before dereferencing and disposing.
Comment 1 Marek Safar 2014-06-24 08:31:54 UTC
Fixed in master