Details
-
Bug
-
Resolution: Fixed
-
Major
-
16.3.0-rc-1
-
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