> From: Claudio Corsi [mailto:[EMAIL PROTECTED]]
> 
> > From: Heikki.Linnakangas�Tietoenator.com
> > 
> > MDC seems to work inproperly with AsyncAppender.
> > 
> > I have a custom appender that reads some entries from the 
> MDC, and writes
> > them to a database. If I use it with the AsyncAppender, the 
> MDC information
> > is sometimes wrong.
> > 
> > The problems seems to be that LoggingEvent.getMDCCopy() 
> doesn't actully
> > create a copy of the hashtable, but just gets a reference to it.
> > 
> > If you modify LoggingEvent.getMDCCopy like this...
> > 
> > 203c203
> > <         mdcCopy = (Hashtable)MDC.getContext().clone();
> > ---
> > >         mdcCopy = MDC.getContext();
> > 
> 
> Heikki,
> 
> I think that you need to consider that the problem might be 
> that the clone
> method is implemented as a shallow copy instead of a deep 
> copy, i.e., the
> default processing of the clone method is to copy references 
> and not the object
> themselves or copy the primitives value. You should look at 
> the implementation
> of the Context class, (and all it sub-classes), clone method 
> to determine that
> this is not the case.

Looks like I created the diff file reversed, sorry about that. So
the problem is that getMDCCopy-method doesn't even try to copy 
the context. I modified the line above so that the mdcCopy is 
created with the clone-method, and that fixed the problem for me.

It's true that cloning won't work either, if the objects that are put
to the hashtable are mutable.

- Heikki

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to