EmptyStackException when rendering macros simultaneously

Details

Description

When two threads are running VelocimacroFactory.startRenderingMacro() simultaneously (same template), both check that templateMap is empty, then both create a new stack, then the second thread put it in templateMap, replacing the one added by the first thread.

At this time we got a stack which size == 1 instead of 2.

Then both threads endProcessingMacros(), both get stack from templateMap and check that its size is > 0, first one empty stack then second pop() macro and gets an EmptyStackException.

Also, just a quick note. Remember when submitting patches in the future to follow the code style guidelines (on our Wiki). We tend to be irritatingly picky about braces on their own line. (Makes the code easier to read). I'll fix them this time.

Will Glass-Husain
added a comment - 10/Oct/07 14:55 Hi Etienne –
Thanks for contributing! (and nice catch). Does "ant test" work?
Also, just a quick note. Remember when submitting patches in the future to follow the code style guidelines (on our Wiki). We tend to be irritatingly picky about braces on their own line. (Makes the code easier to read). I'll fix them this time.