Copilot commented on code in PR #323:
URL: https://github.com/apache/logging-log4net/pull/323#discussion_r4084362434
##########
src/log4net.Tests/Core/FixingTest.cs:
##########
@@ -210,6 +212,45 @@ public void UserNameIsCapturedWhenItIsFixed()
Assert.That(loggingEvent.UserName,
Is.Not.EqualTo(SystemInfo.NotAvailableText));
}
+ /// <summary>
+ /// A redundant Fix must not reopen the cache: a thread reading a field the
event never captured
+ /// would otherwise store its own principal in it. 500000 calls, the defect
hit within 63000.
+ /// </summary>
+ [Test]
+ public void ARedundantFixDoesNotLetAnotherThreadCacheItsIdentity()
+ {
+ LoggingEvent loggingEvent = CreateEvent();
+ // Partial leaves Identity out, so it stays null unless the cache reopens.
+ loggingEvent.Fix = FixFlags.Partial;
+
+ bool stop = false;
+ long spins = 0;
+ TaskCompletionSource<bool> running = new();
+ Thread reader = new(() =>
+ {
+ Thread.CurrentPrincipal = new GenericPrincipal(new
GenericIdentity("Intruder"), null);
+ running.TrySetResult(true);
+ while (!Volatile.Read(ref stop) && loggingEvent.Identity is null)
+ {
+ Interlocked.Increment(ref spins);
Review Comment:
This is a tight busy-spin loop that can peg a CPU core during the test run,
increasing flakiness/timeouts in constrained CI environments. Consider using
`SpinWait` (e.g., `SpinWait.SpinOnce()`), occasional `Thread.Yield()`, or a
wait handle to reduce CPU burn while still exercising the race condition.
##########
src/site/antora/modules/ROOT/pages/manual/configuration/appenders.adoc:
##########
@@ -48,6 +48,8 @@ log4net ships with the following appenders
|AspNetTraceAppender
|Writes logging events to the ASP trace context. These can then be rendered at
the end of the ASP page or on the ASP trace page.
+Writes to the request current on the appending thread, so it must not be
wrapped in a buffering appender.
+
Review Comment:
The added sentence at line 51 is not prefixed like the surrounding table
rows (`||...`). As written, it likely breaks the AsciiDoc table structure or
renders outside the intended cell. Consider appending this note within the same
table cell (e.g., as a continuation of the description cell using the table’s
established syntax) or moving it outside the table block.
--
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]