It's easy to mess with the document in the cache for the other threads by modifying it without cloning it. Since that's a very common mistake, we should ideally find a way to fix that. I can think of two possibility: 1. always return a cloned version of the document in cache 2. before returning the document from the cache, check if it was modified and reload it from the database if that's the case The good thing with 1. is that it's safe, but it makes readonly uses case much slower, and it will clone the XWikiDocument twice in most (currently proper) cases. So I feel the best is 2., but we should also properly fix XWIKI-22510 and make extra sure that any modification leads to a dirty metadata flag set to true (for example, it's not the case right now for some plumbing modifications like the original document). |