Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit a95569a

Browse files
Fix AppDomain.SetPrincipalPolicy bug for new threads (#32104) (#28019)
* fix principal policy for new threads Fixes #31717 Co-authored-by: Marco Rossignoli <[email protected]>
1 parent 25bb13b commit a95569a

File tree

1 file changed

+4
-3
lines changed
  • src/System.Private.CoreLib/shared/System/Threading

1 file changed

+4
-3
lines changed

src/System.Private.CoreLib/shared/System/Threading/Thread.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,12 @@ public static IPrincipal? CurrentPrincipal
136136
{
137137
get
138138
{
139-
if (s_asyncLocalPrincipal is null)
139+
IPrincipal? principal = s_asyncLocalPrincipal?.Value;
140+
if (principal is null)
140141
{
141-
CurrentPrincipal = AppDomain.CurrentDomain.GetThreadPrincipal();
142+
CurrentPrincipal = (principal = AppDomain.CurrentDomain.GetThreadPrincipal());
142143
}
143-
return s_asyncLocalPrincipal?.Value;
144+
return principal;
144145
}
145146
set
146147
{

0 commit comments

Comments
 (0)