gdziadkiewicz commented on code in PR #199:
URL: https://github.com/apache/logging-log4net/pull/199#discussion_r1815747496
##########
src/log4net/Core/LoggingEvent.cs:
##########
@@ -742,15 +742,27 @@ private static string ReviseThreadName(string? threadName)
{
if (_platformDoesNotSupportWindowsIdentity)
{
- // we've already received one PlatformNotSupportedException
+ // we've already received one PlatformNotSupportedException or null from
TryReadWindowsIdentityUserName
// and it's highly unlikely that will change
return Environment.UserName;
}
try
{
- return _cachedWindowsIdentityUserName ??=
- TryReadWindowsIdentityUserName();
+ if(_cachedWindowsIdentityUserName is not null)
+ {
+ return _cachedWindowsIdentityUserName;
+ }
+ else if(TryReadWindowsIdentityUserName() is string userName)
+ {
+ _cachedWindowsIdentityUserName = userName;
+ return _cachedWindowsIdentityUserName;
+ }
+ else
+ {
+ _platformDoesNotSupportWindowsIdentity = true;
+ return Environment.UserName;
+ }
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]