[system] Avoid reflection use to create NtlmSession. Fixes #37732
authorSebastien Pouliot <sebastien@xamarin.com>
Fri, 22 Jan 2016 19:19:46 +0000 (14:19 -0500)
committerSebastien Pouliot <sebastien@xamarin.com>
Fri, 22 Jan 2016 19:19:46 +0000 (14:19 -0500)
commit d2325f1483cd642457a7b2efe402e3c1d414d69d (only since 4.3.2, not
4.3.1) caused the failure when an application is linked.

The use of `GetOrCreateValue` uses reflection to create an `NtlmSession`
instance so the linker won't see it as used anymore (and removes it).

Fixed by avoiding reflection (which will also perform better).

https://bugzilla.xamarin.com/show_bug.cgi?id=37732

mcs/class/System/Mono.Http/NtlmClient.cs

index 00036654b1cca414fea382dcc02d652b84d1a62d..e77553b47da4bd3ddba640b0d8c1f446524ef8dc 100644 (file)
@@ -148,7 +148,7 @@ namespace Mono.Http
                                return null;
 
                        lock (cache) {
-                               var ds = cache.GetOrCreateValue (request);
+                               var ds = cache.GetValue (request, x => new NtlmSession ());
                                return ds.Authenticate (header, webRequest, credentials);
                        }
                }