On Apr 16, 2008, at 10:33 AM, Jacob L. Anawalt wrote:
Dale King wrote:
MDC::put( "key", "value1" );
MDC::put( "key", "value2" );
Without a code example, I must ask; are these MDC::put calls in the
same thread right next to each other?
The attached program correctly swaps keys in 0.9.7. I don't have an
installed 0.10.0 build handy at the moment.
There is no MDC test in the test suite and thread-local storage was
rewritten in 0.10.0, so a regression from 0.9.7 is definitely possible.
Took a while to find an explicit description of what happens when you
call std::map::insert with a duplicate key, but section 17.4.1.7 of
Stroustrup's "The C++ Programming Language: Special Edition" on top of
page 488 says:
".. insertion takes place only if there is not already an element in
the m (map) with that key."
The code in threadspecificdata.cpp just does an insert and does not
check the return value to see if the insert was successful. Looks
like we got caught by a difference between the STL and Java map
behaviors. Either file a bug report or I'll do it and will port any
appropriate log4j MDC tests over and fix the issue in a few days.