LeadAssimilator commented on issue #247: URL: https://github.com/apache/logging-log4net/issues/247#issuecomment-2900822954
The caching logic is broken in AbsoluteTimeDateFormatter.FormatDate. _sLastTimeToTheSecond is set by the first FormatDate call on type A with the current time, then when type B calls FormatDate with the same time, it thinks the nothing has changed and returns its really old, cached time string. Also ConcurrentDictionary's update lambda provides no useful synchronization outside of itself afaik making the usage of _sLastTimeToTheSecond potentially unsafe (even if the code was otherwise working properly, the wrong string could still get returned sometimes). I think the quickest/easiest solution to both problems is to move _sLastTimeToTheSecond into the dictionary value - i.e. store a tuple of both timeToTheSecond and timeString in the dictionary: ```csharp private static readonly ConcurrentDictionary<Type, (long timeToTheSecond, string timeString)> _sLastTimeStrings = new(); ``` -- 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: notifications-unsubscr...@logging.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org