Velocity
  1. Velocity
  2. VELOCITY-566

EmptyStackException when rendering macros simultaneously

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6
    • Fix Version/s: 1.6
    • Component/s: Engine
    • Labels:
      None

      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.

      behavior was introduced by improvement VELOCITY-297.

      patch is joined, synchronize(templateMap) in VelocimacroFactory.startRenderingMacro().

        Activity

        Etienne Massip created issue -
        Etienne Massip made changes -
        Field Original Value New Value
        Attachment emptyStackExceptionMacrosVTL.patch [ 12367459 ]
        Hide
        Will Glass-Husain added a comment -

        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.

        Show
        Will Glass-Husain added a comment - 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.
        Hide
        Etienne Massip added a comment -

        I forgot that brace thing, sorry. Yes, "ant test" does work.

        Thanks !

        Show
        Etienne Massip added a comment - I forgot that brace thing, sorry. Yes, "ant test" does work. Thanks !
        Hide
        Will Glass-Husain added a comment -

        patch committed - thanks!

        Show
        Will Glass-Husain added a comment - patch committed - thanks!
        Will Glass-Husain made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Etienne Massip made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Workflow jira [ 12414679 ] Default workflow, editable Closed status [ 12551525 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12551525 ] jira [ 12552412 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Etienne Massip
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development