Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-22215

XWikiDocument#getPreparedXDOM can run the preparation on the same XDOM instance in several threads

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 16.5.0-rc-1, 16.4.1
    • 16.3.0-rc-1
    • Old Core
    • None
    • Unknown
    • N/A
    • N/A

    Description

      Consider the following operations on an instance of XWikiDocument where
      xdomCachePrepareDate and xdomCache are initially null.

      • Thread 1 calls getXDOM(). this.xdomCache = parseContentNoException(); is executed.
      • Thread 1 calls getPreparedXDOM() and starts calling getMacroTransformation().prepare(xdom);
      • Thread 2 also calls getPreparedXDOM() and also calls getMacroTransformation().prepare(xdom); as xdomCachePrepareDate is still null

      I can think of two things:

      • the ideal for performance would probably be to add some read/write locking in `getPreparedXDOM()` to avoid preparing the content several times
      • the other possibility is to clone the `this.xdomCache` before preparing it, simpler and `getXDOM()` won't return a half prepared XDOM but cost a bit more

      Attachments

        Activity

          People

            tmortagne Thomas Mortagne
            tmortagne Thomas Mortagne
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: