This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
[release/3.1] Port dotnet/runtime#32104 fix for Thread.CurrentPrincipal regression #28019
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backports a fix for issue dotnet/runtime#31717 which concerns a regression in the behaviour of the
Thread.CurrentPrincipal
property, introduced in 3.0.This has already been fixed in .NET 5 (see dotnet/runtime#32104). This PR ports that fix down to release/3.1.
Customer Impact
Assigning a PrincipalPolicy to the current AppDomain results in the first thread correctly returning
Thread.CurrentPrincipal
. However it will consistently returnnull
for any subsequent threads. There are no known workarounds to this issue.Regression?
Functional regression between 2.1 and 3.0 here - original issue here). Reported by 2 customers.
Testing
The .NET 5 fix at dotnet/runtime#32104 includes tests for the fix.
Risk
Moderate. The regression was introduced in an attempt to introduce new behaviour (i.e. flowing the principal with ExecutionContext), but this was broken in all but the most trivial scenaria (using just one thread). It is conceivable that fixing this might expose other problems, or in the very least break applications written against 3.0 that implicitly depend on the current behaviour of the property.
Code Reviewer
@jkotas