https://bugzilla.novell.com/show_bug.cgi?id=658689
https://bugzilla.novell.com/show_bug.cgi?id=658689#c0 Summary: ThreadLocal<T> where T is an interface - uninitialized value throws exception Classification: Mono Product: Mono: Class Libraries Version: SVN Platform: All OS/Version: All Status: NEW Severity: Normal Priority: P5 - None Component: CORLIB AssignedTo: [email protected] ReportedBy: [email protected] QAContact: [email protected] Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.215 Safari/534.10 Given the following code class MainClass { public static void Main (string[] args) { ThreadLocal<IPointlessActions> newLocal = new ThreadLocal<IPointlessActions>(); bool willThrowAnException = newLocal.Value == null; } } public interface IPointlessActions { void DoSomething(); } We will get an exception, on the MS implementation it will return null. http://msdn.microsoft.com/en-us/library/dd642283.aspx The documentation states If this instance was not previously initialized for the current thread, accessing Value will attempt to initialize it. If an initialization function was supplied during the construction, that initialization will happen by invoking the function to retrieve the initial value for Value. Otherwise, the default value of will be used. If an exception is thrown, that exception is cached and thrown on each subsequent access of the property. This to me suggests default(T) I have/will be very shortly submitting a pull request via Github for this issue. Reproducible: Always Steps to Reproduce: 1.Run the code above Actual Results: Exception gets thrown Expected Results: Null should be returned -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug. You are the assignee for the bug. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
