Bug 9155

Summary: LoggingEvent.getMDCCopy() should set mdcLookupRequired = false
Product: Log4j - Now in Jira Reporter: Nicko Cadell <apache-bugs>
Component: OtherAssignee: log4j-dev <log4j-dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 1.2   
Target Milestone: ---   
Hardware: All   
OS: other   

Description Nicko Cadell 2002-05-16 13:22:56 UTC
In the following method in LoggingEvent.java

  public
  void getMDCCopy() {
    if(mdcLookupRequired) {
      ndcLookupRequired = false;
      // the clone call is required for asynchronous logging.
      // See also bug #5932.
      Hashtable t = (Hashtable) MDC.getContext();
      if(t != null) {
	mdcCopy = (Hashtable) t.clone();
      }
    }
  }

ndcLookupRequired is set to false when it should be mdcLookupRequired which is 
set to false.
Comment 1 Ceki Gulcu 2002-05-17 10:27:40 UTC
Good catch! I'll fix it immediately and will release log4j 1.2.1 afterwards. By 
the way, did you detect this bug by reading the code or by observing at 
deployment time? Regards, Ceki

ps: I'll also add a test case in order detect such silly errors as early as 
possible.
Comment 2 Nicko Cadell 2002-05-17 10:36:38 UTC
I spotted this reading the code (or rather using find). I don't think that this 
would actualy have an issue in a deployed system. The only issues would be if 
you called getMDCCopy() before calling getNDC() which would then not cache the 
NDC localy. However you don't do that so it should be ok.