Details
-
Bug
-
Resolution: Fixed
-
Major
-
3.0 M2
-
patch, bugfixingday
-
Trivial
-
Description
I noticed this potential race condition:
if (getDocumentArchive() != null) { return getDocumentArchive(); }
The soft reference may theoretically be garbage collected between the calls. I'm not sure that this could happen in practice, as the document archive must have been loaded using a different context than the current one. But if getDocumentArchive is called only once, the race condition obviously cannot occur:
Index: xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java
===================================================================
--- xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java (revision 34604)
+++ xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java (working copy)
@@ -1740,14 +1740,15 @@
*/
public XWikiDocumentArchive loadDocumentArchive()
{
- if (getDocumentArchive() != null) {
- return getDocumentArchive();
+ XWikiDocumentArchive arch = getDocumentArchive();
+ if (arch != null) {
+ return arch;
}
XWikiContext xcontext = getXWikiContext();
try {
- XWikiDocumentArchive arch = getVersioningStore(xcontext).getXWikiDocumentArchive(this, xcontext);
+ arch = getVersioningStore(xcontext).getXWikiDocumentArchive(this, xcontext);
// Put a copy of the archive in the soft reference for later use if needed.
setDocumentArchive(arch);