Bug 9155 - LoggingEvent.getMDCCopy() should set mdcLookupRequired = false
Summary: LoggingEvent.getMDCCopy() should set mdcLookupRequired = false
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.2
Hardware: All other
: P3 normal
Target Milestone: ---
Assignee: log4j-dev
Depends on:
Reported: 2002-05-16 13:22 UTC by Nicko Cadell
Modified: 2004-11-16 19:05 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Nicko Cadell 2002-05-16 13:22:56 UTC
In the following method in LoggingEvent.java

  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 
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.