Uploaded image for project: 'Commons Jelly'
  1. Commons Jelly
  2. JELLY-113

TagSupport concurrency issue

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0-beta-4
    • core / taglib.core
    • None

    Description

      Assume you have a jelly tag <j:jelly> with children. The following sequence leads to concurrency problems:

      1. Instance 1 of Tag is created on thread 1. Body is ScriptBlock
      2. Instance 2 of Tag is created on thread 2. Body is same ScriptBlock as Instance 1.
      3. doTag -> invokeBody -> getBody -> trimBody is called for Instance 1
      4. same for instance 2
      5. Instance 1 gets the size of the ScriptBlock
      6. Instance 2 gets the size of the ScriptBlock
      7. Instance 1 trims whitespace blocks
      8. Instance 2 gets an IndexOutOfBounds exception since it resumes execution with an incorrect list size (list was changed by Instance 1).

      Both threads concurrently trim the same ScriptBody (the hasTrimmed variable is instance-specific). The attached patch synchronizes access to the body within trimBody.

      Attachments

        1. TagSupport.java
          11 kB
          Gary Franklin
        2. TagSupportPatch.txt
          10 kB
          Gary Franklin

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            diongillard dion gillard
            gsfranklin Gary Franklin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment